Merge "[magma] Add device query fudge method"

GitOrigin-RevId: 3d08ffd8b7f2d597d782980a48eb76d13867902f
Change-Id: Ia738147c62bf9c7c6ee9df7abcb6fe3ed1db3873
diff --git a/protocols/magma/README b/protocols/magma/README
deleted file mode 100644
index 527041d..0000000
--- a/protocols/magma/README
+++ /dev/null
@@ -1,6 +0,0 @@
-The files in this directory were generated using
-third-party/fuchsia/magma/regen.py and reflect the standard magma protocol.
-However, as emugen does not have the ability to generate binding code for nested
-pointers, some method signatures must be modified to use a packed format. For
-clarity, these are defined alongside the original (disabled) signatures and
-labeled "fudge" methods.
diff --git a/protocols/magma/README.md b/protocols/magma/README.md
new file mode 100644
index 0000000..1360e35
--- /dev/null
+++ b/protocols/magma/README.md
@@ -0,0 +1,118 @@
+# Magma Emugen Interface Definition
+
+The files in this directory were generated using
+third-party/fuchsia/magma/regen.py and reflect the standard magma protocol.
+However, as emugen does not have the ability to generate binding code for nested
+pointers, some method signatures must be modified to use a packed format. For
+clarity, these are defined alongside the original (disabled) signatures and
+labeled "fudge" methods.
+
+## Fudge Methods
+
+The following describes how fudge methods differ from their original methods.
+
+### `magma_device_query_fudge`
+
+If `magma_device_query` for the given query `id` returns a value in `result_out`, then the method populates the value and other fudge parameters are ignored. Otherwise, if `host_allocate` is 1, `result_buffer_mapping_id_inout` is populated with a host-allocated buffer mapping ID, and `result_buffer_size_inout` is populated with this buffer's size. If `host_allocate` is 0, the host looks at the value passed to `result_buffer_size_inout`. If the size is too small for the query data (including value `0`), `result_buffer_mapping_id_inout` is ignored and `result_buffer_size_inout` is set to the minimum buffer size required. Otherwise, `result_buffer_size_inout` is unchanged and the host uses `result_buffer_mapping_id_inout` to map and populate the result buffer contents. Note that as certain queries may return a variable amount of data, clients should query in a loop to ensure all data is successfully retrieved.
+
+#### Examples
+
+##### Basic Query
+
+```cpp
+uint64_t buffer_mapping_id = 0;
+uint64_t buffer_size = 0;
+uint64_t result = 0;
+magma_device_query_fudge(
+    device,
+    MAGMA_QUERY_VENDOR_ID,
+    /* host_allocate = */ 0,
+    &buffer_mapping_id, // Ignored and unchanged
+    &buffer_size, // Ignored and unchanged
+    &result); // Populated with VENDOR_ID
+```
+
+##### Host-Allocated Query
+
+```cpp
+uint64_t buffer_mapping_id = 0;
+uint64_t buffer_size = 0;
+uint64_t result = 0;
+magma_device_query_fudge(
+    device,
+    MAGMA_QUERY_TOTAL_TIME,
+    /* host_allocate = */ 1,
+    &buffer_mapping_id, // Populated with mapping ID
+    &buffer_size, // Populated with buffer size
+    &result); // Ignored and unchanged
+```
+
+##### Guest-Allocated Query
+
+Note that in the following example, the query always returns a fixed-size `magma_total_time_query_result_t`. Although the client could have allocated a buffer sufficiently large to hold this data up front, a loop is used to illustrate handling of variable-size queries, as may be encountered in vendor-specific queries.
+
+```cpp
+uint64_t buffer_mapping_id = 0;
+uint64_t buffer_size = 0;
+uint64_t result = 0;
+
+uint64_t allocated_size = 0;
+GuestBuffer buffer;
+do {
+    if (buffer_size > 0) {
+        CreateBufferWithMappingId(buffer_size, &buffer, &buffer_mapping_id);
+        allocated_size = buffer_size;
+    }
+    // On the first pass, buffer_mapping_id is ignored,
+    // and buffer_size populated with the required size.
+    // On subsequent passes, an allocated buffer and its
+    // size are passed. If the buffer is sufficiently large,
+    // the buffer contents are populated and the loop exits.
+    // Otherwise, a larger buffer is allocated and the query
+    // is attempted again.
+    magma_device_query_fudge(
+        device,
+        MAGMA_QUERY_TOTAL_TIME,
+        /* host_allocate = */ 0,
+        &buffer_mapping_id,
+        &buffer_size,
+        &result); // Ignored and unchanged
+} while (allocated_size < buffer_size);
+```
+
+### `magma_connection_execute_command_fudge`
+
+This method has the same semantics as `magma_connection_execute_command`, however `descriptor` points to `descriptor_size` bytes that contain a packed `magma_command_descriptor_t` using the following tightly-packed format:
+
+```cpp
+uint32_t resource_count;
+uint32_t command_buffer_count;
+uint32_t wait_semaphore_count;
+uint32_t signal_semaphore_count;
+uint64_t flags;
+magma_exec_resource_t resources[resource_count];
+magma_exec_command_buffer_t command_buffers[command_buffer_count];
+uint64_t semaphore_ids[signal_semaphore_count];
+```
+
+### `magma_connection_execute_immediate_commands_fudge`
+
+This method has the same semantics as `magma_connection_execute_immediate_commands`, however `command_buffers` points to `command_buffers_size` bytes containing a list of packed `magma_inline_command_buffer_t` structs. The offset to each packed `magma_inline_command_buffer_t` is defined by the elements of `command_buffer_offsets`. Each `magma_inline_command_buffer_t` is encoded using the following tightly-packed format:
+
+```cpp
+uint64_t size;
+uint32_t semaphore_count;
+uint32_t padding;
+uint64_t semaphore_ids[semaphore_count];
+uint8_t data[size];
+```
+
+### `magma_buffer_set_name_fudge`
+
+This method has the same semantics as `magma_buffer_set_name`, however `name_size` should be set to the number of bytes that should be used to define `name`. This should not include the terminating null character.
+
+#### Example
+
+```cpp
+magma_buffer_set_name_fudge(buffer, "MyBuf", 5);
+```
diff --git a/protocols/magma/magma.attrib b/protocols/magma/magma.attrib
index edbda0c..9227c42 100644
--- a/protocols/magma/magma.attrib
+++ b/protocols/magma/magma.attrib
@@ -15,6 +15,14 @@
 	dir result_out out
 	len result_out sizeof(uint64_t)
 
+magma_device_query_fudge
+	dir result_buffer_mapping_id_inout inout
+	len result_buffer_mapping_id_inout sizeof(uint64_t)
+	dir result_buffer_size_inout inout
+	len result_buffer_size_inout sizeof(uint64_t)
+	dir result_out out
+	len result_out sizeof(uint64_t)
+
 magma_device_create_connection
 	dir connection_out out
 	len connection_out sizeof(magma_connection_t)
diff --git a/protocols/magma/magma.in b/protocols/magma/magma.in
index b76a669..41727c3 100644
--- a/protocols/magma/magma.in
+++ b/protocols/magma/magma.in
@@ -1,6 +1,7 @@
 MAGMA(magma_status_t, magma_device_import, magma_handle_t device_channel, magma_device_t* device_out)
 MAGMA(void, magma_device_release, magma_device_t device)
 MAGMA(magma_status_t, magma_device_query, magma_device_t device, uint64_t id, magma_handle_t* result_buffer_out, uint64_t* result_out)
+MAGMA(magma_status_t, magma_device_query_fudge, magma_device_t device, uint64_t id, magma_bool_t host_allocate, uint64_t* result_buffer_mapping_id_inout, uint64_t* result_buffer_size_inout, uint64_t* result_out)
 MAGMA(magma_status_t, magma_device_create_connection, magma_device_t device, magma_connection_t* connection_out)
 MAGMA(void, magma_connection_release, magma_connection_t connection)
 MAGMA(magma_status_t, magma_connection_get_error, magma_connection_t connection)
diff --git a/protocols/magma/magma.types b/protocols/magma/magma.types
index 6ed6193..b2d927b 100644
--- a/protocols/magma/magma.types
+++ b/protocols/magma/magma.types
@@ -1,4 +1,5 @@
 # Magma types.
+magma_bool_t 8 %hhu false
 magma_buffer_t 64 %lu false
 magma_cache_operation_t 32 %u false
 magma_cache_policy_t 32 %u false
diff --git a/stream-servers/magma/Decoder.cpp b/stream-servers/magma/Decoder.cpp
index 11319ab..6ae5fe3 100644
--- a/stream-servers/magma/Decoder.cpp
+++ b/stream-servers/magma/Decoder.cpp
@@ -86,6 +86,7 @@
     MAGMA_DECODER_BIND_METHOD(magma_virt_connection_get_image_info);
 
     // Bind fudged methods.
+    MAGMA_DECODER_BIND_METHOD(magma_device_query_fudge);
     MAGMA_DECODER_BIND_METHOD(magma_connection_execute_command_fudge);
     MAGMA_DECODER_BIND_METHOD(magma_connection_execute_immediate_commands_fudge);
     MAGMA_DECODER_BIND_METHOD(magma_buffer_set_name_fudge);
@@ -368,6 +369,15 @@
     return MAGMA_STATUS_UNIMPLEMENTED;
 }
 
+magma_status_t Decoder::magma_device_query_fudge(magma_device_t device, uint64_t id,
+                                                 magma_bool_t host_allocate,
+                                                 uint64_t* result_buffer_mapping_id_inout,
+                                                 uint64_t* result_buffer_size_inout,
+                                                 uint64_t* result_out) {
+    MAGMA_NOTIMPL();
+    return MAGMA_STATUS_UNIMPLEMENTED;
+}
+
 magma_status_t Decoder::magma_connection_execute_command_fudge(magma_connection_t connection,
                                                                uint32_t context_id,
                                                                void* descriptor,
diff --git a/stream-servers/magma/Decoder.h b/stream-servers/magma/Decoder.h
index 387f66e..3ace5df 100644
--- a/stream-servers/magma/Decoder.h
+++ b/stream-servers/magma/Decoder.h
@@ -35,6 +35,7 @@
     virtual magma_status_t magma_device_import(magma_handle_t device_channel, magma_device_t* device_out);
     virtual void magma_device_release(magma_device_t device);
     virtual magma_status_t magma_device_query(magma_device_t device, uint64_t id, magma_handle_t* result_buffer_out, uint64_t* result_out);
+    virtual magma_status_t magma_device_query_fudge(magma_device_t device, uint64_t id, magma_bool_t host_allocate, uint64_t* result_buffer_mapping_id_inout, uint64_t* result_buffer_size_inout, uint64_t* result_out);
     virtual magma_status_t magma_device_create_connection(magma_device_t device, magma_connection_t* connection_out);
     virtual void magma_connection_release(magma_connection_t connection);
     virtual magma_status_t magma_connection_get_error(magma_connection_t connection);
diff --git a/stream-servers/magma/magma_dec/magma_dec.cpp b/stream-servers/magma/magma_dec/magma_dec.cpp
index 510bc25..1b30a5c 100644
--- a/stream-servers/magma/magma_dec/magma_dec.cpp
+++ b/stream-servers/magma/magma_dec/magma_dec.cpp
@@ -105,6 +105,44 @@
 			android::base::endTrace();
 			break;
 		}
+		case OP_magma_device_query_fudge: {
+			android::base::beginTrace("magma_device_query_fudge decode");
+			magma_device_t var_device = Unpack<magma_device_t,uint64_t>(ptr + 8);
+			uint64_t var_id = Unpack<uint64_t,uint64_t>(ptr + 8 + 8);
+			magma_bool_t var_host_allocate = Unpack<magma_bool_t,uint8_t>(ptr + 8 + 8 + 8);
+			uint32_t size_result_buffer_mapping_id_inout __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8 + 8 + 8 + 1);
+			InputBuffer inptr_result_buffer_mapping_id_inout(ptr + 8 + 8 + 8 + 1 + 4, size_result_buffer_mapping_id_inout);
+			uint32_t size_result_buffer_size_inout __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8 + 8 + 8 + 1 + 4 + size_result_buffer_mapping_id_inout);
+			InputBuffer inptr_result_buffer_size_inout(ptr + 8 + 8 + 8 + 1 + 4 + size_result_buffer_mapping_id_inout + 4, size_result_buffer_size_inout);
+			uint32_t size_result_out __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8 + 8 + 8 + 1 + 4 + size_result_buffer_mapping_id_inout + 4 + size_result_buffer_size_inout);
+			if (useChecksum) {
+				ChecksumCalculatorThreadInfo::validOrDie(checksumCalc, ptr, 8 + 8 + 8 + 1 + 4 + size_result_buffer_mapping_id_inout + 4 + size_result_buffer_size_inout + 4, ptr + 8 + 8 + 8 + 1 + 4 + size_result_buffer_mapping_id_inout + 4 + size_result_buffer_size_inout + 4, checksumSize,
+					"magma_decoder_context_t::decode, OP_magma_device_query_fudge: GL checksumCalculator failure\n");
+			}
+			size_t totalTmpSize = size_result_buffer_mapping_id_inout;
+			totalTmpSize += size_result_buffer_size_inout;
+			totalTmpSize += size_result_out;
+			totalTmpSize += sizeof(magma_status_t);
+			totalTmpSize += checksumSize;
+			unsigned char *tmpBuf = stream->alloc(totalTmpSize);
+			OutputBuffer outptr_result_buffer_mapping_id_inout(&tmpBuf[0], size_result_buffer_mapping_id_inout);
+			memcpy(outptr_result_buffer_mapping_id_inout.get(), inptr_result_buffer_mapping_id_inout.get(), size_result_buffer_mapping_id_inout);
+			OutputBuffer outptr_result_buffer_size_inout(&tmpBuf[0 + size_result_buffer_mapping_id_inout], size_result_buffer_size_inout);
+			memcpy(outptr_result_buffer_size_inout.get(), inptr_result_buffer_size_inout.get(), size_result_buffer_size_inout);
+			OutputBuffer outptr_result_out(&tmpBuf[0 + size_result_buffer_mapping_id_inout + size_result_buffer_size_inout], size_result_out);
+			DECODER_DEBUG_LOG("magma(%p): magma_device_query_fudge(device:%lu id:%lu host_allocate:%hhu result_buffer_mapping_id_inout:%p(%u) result_buffer_size_inout:%p(%u) result_out:%p(%u) )", stream, var_device, var_id, var_host_allocate, (uint64_t*)(outptr_result_buffer_mapping_id_inout.get()), size_result_buffer_mapping_id_inout, (uint64_t*)(outptr_result_buffer_size_inout.get()), size_result_buffer_size_inout, (uint64_t*)(outptr_result_out.get()), size_result_out);
+			*(magma_status_t *)(&tmpBuf[0 + size_result_buffer_mapping_id_inout + size_result_buffer_size_inout + size_result_out]) = 			this->magma_device_query_fudge(var_device, var_id, var_host_allocate, (uint64_t*)(outptr_result_buffer_mapping_id_inout.get()), (uint64_t*)(outptr_result_buffer_size_inout.get()), (uint64_t*)(outptr_result_out.get()));
+			outptr_result_buffer_mapping_id_inout.flush();
+			outptr_result_buffer_size_inout.flush();
+			outptr_result_out.flush();
+			if (useChecksum) {
+				ChecksumCalculatorThreadInfo::writeChecksum(checksumCalc, &tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize);
+			}
+			stream->flush();
+			SET_LASTCALL("magma_device_query_fudge");
+			android::base::endTrace();
+			break;
+		}
 		case OP_magma_device_create_connection: {
 			android::base::beginTrace("magma_device_create_connection decode");
 			magma_device_t var_device = Unpack<magma_device_t,uint64_t>(ptr + 8);
diff --git a/stream-servers/magma/magma_dec/magma_opcodes.h b/stream-servers/magma/magma_dec/magma_opcodes.h
index f1b6a10..955944f 100644
--- a/stream-servers/magma/magma_dec/magma_opcodes.h
+++ b/stream-servers/magma/magma_dec/magma_opcodes.h
@@ -6,53 +6,54 @@
 #define OP_magma_device_import 					100000
 #define OP_magma_device_release 					100001
 #define OP_magma_device_query 					100002
-#define OP_magma_device_create_connection 					100003
-#define OP_magma_connection_release 					100004
-#define OP_magma_connection_get_error 					100005
-#define OP_magma_connection_create_context 					100006
-#define OP_magma_connection_release_context 					100007
-#define OP_magma_connection_create_buffer 					100008
-#define OP_magma_connection_release_buffer 					100009
-#define OP_magma_connection_import_buffer 					100010
-#define OP_magma_connection_create_semaphore 					100011
-#define OP_magma_connection_release_semaphore 					100012
-#define OP_magma_connection_import_semaphore 					100013
-#define OP_magma_connection_perform_buffer_op 					100014
-#define OP_magma_connection_map_buffer 					100015
-#define OP_magma_connection_unmap_buffer 					100016
-#define OP_magma_connection_execute_command 					100017
-#define OP_magma_connection_execute_command_fudge 					100018
-#define OP_magma_connection_execute_immediate_commands 					100019
-#define OP_magma_connection_execute_immediate_commands_fudge 					100020
-#define OP_magma_connection_flush 					100021
-#define OP_magma_connection_get_notification_channel_handle 					100022
-#define OP_magma_connection_read_notification_channel 					100023
-#define OP_magma_buffer_clean_cache 					100024
-#define OP_magma_buffer_set_cache_policy 					100025
-#define OP_magma_buffer_get_cache_policy 					100026
-#define OP_magma_buffer_set_name 					100027
-#define OP_magma_buffer_set_name_fudge 					100028
-#define OP_magma_buffer_get_info 					100029
-#define OP_magma_buffer_get_handle 					100030
-#define OP_magma_buffer_export 					100031
-#define OP_magma_semaphore_signal 					100032
-#define OP_magma_semaphore_reset 					100033
-#define OP_magma_semaphore_export 					100034
-#define OP_magma_poll 					100035
-#define OP_magma_initialize_tracing 					100036
-#define OP_magma_initialize_logging 					100037
-#define OP_magma_connection_enable_performance_counter_access 					100038
-#define OP_magma_connection_enable_performance_counters 					100039
-#define OP_magma_connection_create_performance_counter_buffer_pool 					100040
-#define OP_magma_connection_release_performance_counter_buffer_pool 					100041
-#define OP_magma_connection_add_performance_counter_buffer_offsets_to_pool 					100042
-#define OP_magma_connection_remove_performance_counter_buffer_from_pool 					100043
-#define OP_magma_connection_dump_performance_counters 					100044
-#define OP_magma_connection_clear_performance_counters 					100045
-#define OP_magma_connection_read_performance_counter_completion 					100046
-#define OP_magma_virt_connection_create_image 					100047
-#define OP_magma_virt_connection_get_image_info 					100048
-#define OP_last 					100049
+#define OP_magma_device_query_fudge 					100003
+#define OP_magma_device_create_connection 					100004
+#define OP_magma_connection_release 					100005
+#define OP_magma_connection_get_error 					100006
+#define OP_magma_connection_create_context 					100007
+#define OP_magma_connection_release_context 					100008
+#define OP_magma_connection_create_buffer 					100009
+#define OP_magma_connection_release_buffer 					100010
+#define OP_magma_connection_import_buffer 					100011
+#define OP_magma_connection_create_semaphore 					100012
+#define OP_magma_connection_release_semaphore 					100013
+#define OP_magma_connection_import_semaphore 					100014
+#define OP_magma_connection_perform_buffer_op 					100015
+#define OP_magma_connection_map_buffer 					100016
+#define OP_magma_connection_unmap_buffer 					100017
+#define OP_magma_connection_execute_command 					100018
+#define OP_magma_connection_execute_command_fudge 					100019
+#define OP_magma_connection_execute_immediate_commands 					100020
+#define OP_magma_connection_execute_immediate_commands_fudge 					100021
+#define OP_magma_connection_flush 					100022
+#define OP_magma_connection_get_notification_channel_handle 					100023
+#define OP_magma_connection_read_notification_channel 					100024
+#define OP_magma_buffer_clean_cache 					100025
+#define OP_magma_buffer_set_cache_policy 					100026
+#define OP_magma_buffer_get_cache_policy 					100027
+#define OP_magma_buffer_set_name 					100028
+#define OP_magma_buffer_set_name_fudge 					100029
+#define OP_magma_buffer_get_info 					100030
+#define OP_magma_buffer_get_handle 					100031
+#define OP_magma_buffer_export 					100032
+#define OP_magma_semaphore_signal 					100033
+#define OP_magma_semaphore_reset 					100034
+#define OP_magma_semaphore_export 					100035
+#define OP_magma_poll 					100036
+#define OP_magma_initialize_tracing 					100037
+#define OP_magma_initialize_logging 					100038
+#define OP_magma_connection_enable_performance_counter_access 					100039
+#define OP_magma_connection_enable_performance_counters 					100040
+#define OP_magma_connection_create_performance_counter_buffer_pool 					100041
+#define OP_magma_connection_release_performance_counter_buffer_pool 					100042
+#define OP_magma_connection_add_performance_counter_buffer_offsets_to_pool 					100043
+#define OP_magma_connection_remove_performance_counter_buffer_from_pool 					100044
+#define OP_magma_connection_dump_performance_counters 					100045
+#define OP_magma_connection_clear_performance_counters 					100046
+#define OP_magma_connection_read_performance_counter_completion 					100047
+#define OP_magma_virt_connection_create_image 					100048
+#define OP_magma_virt_connection_get_image_info 					100049
+#define OP_last 					100050
 
 
 #endif
diff --git a/stream-servers/magma/magma_dec/magma_server_context.cpp b/stream-servers/magma/magma_dec/magma_server_context.cpp
index a9a30ff..b72f80a 100644
--- a/stream-servers/magma/magma_dec/magma_server_context.cpp
+++ b/stream-servers/magma/magma_dec/magma_server_context.cpp
@@ -13,6 +13,7 @@
 	magma_device_import = (magma_device_import_server_proc_t) getProc("magma_device_import", userData);
 	magma_device_release = (magma_device_release_server_proc_t) getProc("magma_device_release", userData);
 	magma_device_query = (magma_device_query_server_proc_t) getProc("magma_device_query", userData);
+	magma_device_query_fudge = (magma_device_query_fudge_server_proc_t) getProc("magma_device_query_fudge", userData);
 	magma_device_create_connection = (magma_device_create_connection_server_proc_t) getProc("magma_device_create_connection", userData);
 	magma_connection_release = (magma_connection_release_server_proc_t) getProc("magma_connection_release", userData);
 	magma_connection_get_error = (magma_connection_get_error_server_proc_t) getProc("magma_connection_get_error", userData);
diff --git a/stream-servers/magma/magma_dec/magma_server_context.h b/stream-servers/magma/magma_dec/magma_server_context.h
index 7ddfee0..aa96017 100644
--- a/stream-servers/magma/magma_dec/magma_server_context.h
+++ b/stream-servers/magma/magma_dec/magma_server_context.h
@@ -13,6 +13,7 @@
 	magma_device_import_server_proc_t magma_device_import;
 	magma_device_release_server_proc_t magma_device_release;
 	magma_device_query_server_proc_t magma_device_query;
+	magma_device_query_fudge_server_proc_t magma_device_query_fudge;
 	magma_device_create_connection_server_proc_t magma_device_create_connection;
 	magma_connection_release_server_proc_t magma_connection_release;
 	magma_connection_get_error_server_proc_t magma_connection_get_error;
diff --git a/stream-servers/magma/magma_dec/magma_server_proc.h b/stream-servers/magma/magma_dec/magma_server_proc.h
index b7dec32..fdc5b87 100644
--- a/stream-servers/magma/magma_dec/magma_server_proc.h
+++ b/stream-servers/magma/magma_dec/magma_server_proc.h
@@ -15,6 +15,7 @@
 typedef magma_status_t (magma_APIENTRY *magma_device_import_server_proc_t) (magma_handle_t, magma_device_t*);
 typedef void (magma_APIENTRY *magma_device_release_server_proc_t) (magma_device_t);
 typedef magma_status_t (magma_APIENTRY *magma_device_query_server_proc_t) (magma_device_t, uint64_t, magma_handle_t*, uint64_t*);
+typedef magma_status_t (magma_APIENTRY *magma_device_query_fudge_server_proc_t) (magma_device_t, uint64_t, magma_bool_t, uint64_t*, uint64_t*, uint64_t*);
 typedef magma_status_t (magma_APIENTRY *magma_device_create_connection_server_proc_t) (magma_device_t, magma_connection_t*);
 typedef void (magma_APIENTRY *magma_connection_release_server_proc_t) (magma_connection_t);
 typedef magma_status_t (magma_APIENTRY *magma_connection_get_error_server_proc_t) (magma_connection_t);