@@ -427,7 +427,7 @@ struct virtbuffer {
427427 * static size_t cont_len = 0;
428428 *
429429 * static void
430- * modify_content(size_t n, struct virtbuffer buffers[n ], size_t res)
430+ * modify_content(size_t n, struct virtbuffer buffers[], size_t res)
431431 * {
432432 * // Allocate a new zero-terminated buffer from input
433433 * char *new_buf = malloc(buffers[0].len + 1);
@@ -443,7 +443,7 @@ struct virtbuffer {
443443 * storage_return_nothing();
444444 * }
445445 * static void
446- * get_content(size_t n, struct virtbuffer buffers[n ], size_t res)
446+ * get_content(size_t n, struct virtbuffer buffers[], size_t res)
447447 * {
448448 * storage_return(cont, cont_len);
449449 * }
@@ -472,15 +472,15 @@ struct virtbuffer {
472472 * from the function. This allows the system to copy the data back to the
473473 * request program before the function has returned and deallocated the data.
474474**/
475- typedef void (* storage_func ) (size_t n , struct virtbuffer [n ], size_t res );
475+ typedef void (* storage_func ) (size_t n , struct virtbuffer [], size_t res );
476476
477477/* Returns true (1) if called from storage. */
478478extern int
479479sys_is_storage ();
480480
481481/* Transfer an array of buffers to storage, transfer output into @dst. */
482482extern long
483- storage_callv (storage_func , size_t n , const struct virtbuffer [n ], void * dst , size_t );
483+ storage_callv (storage_func , size_t n , const struct virtbuffer [], void * dst , size_t );
484484
485485/* Transfer an array to storage, transfer output into @dst. */
486486static inline long
@@ -599,7 +599,13 @@ extern struct shared_memory_info shared_memory_area();
599599
600600/* Allocate pointers to shared memory with given size and alignment. */
601601#define SHM_ALLOC_BYTES (x ) internal_shm_alloc(x, 8)
602- #define SHM_ALLOC_TYPE (x ) (typeof(x) *)internal_shm_alloc(sizeof(x), _Alignof(x))
602+ #ifdef __cplusplus
603+ #define SHM_ALLOC_TYPE (x ) (x *)internal_shm_alloc(sizeof(x), alignof(x))
604+ #define SHM_ALLOC (x ) (decltype(x) *)internal_shm_alloc(sizeof(x), alignof(x))
605+ #else
606+ #define SHM_ALLOC_TYPE (x ) (x *)internal_shm_alloc(sizeof(x), _Alignof(x))
607+ #define SHM_ALLOC (x ) (typeof(x) *)internal_shm_alloc(sizeof(x), _Alignof(x))
608+ #endif
603609static inline void * internal_shm_alloc (size_t size , size_t align ) {
604610 static struct shared_memory_info info ;
605611 if (info .ptr == 0x0 ) {
0 commit comments