jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.2KB

  1. #ifndef __jack_shm_h__
  2. #define __jack_shm_h__
  3. #include <limits.h>
  4. #include <sys/types.h>
  5. #include <jack/types.h>
  6. #define MAX_SHM_ID 256 /* likely use is more like 16 per jackd */
  7. #ifdef USE_POSIX_SHM
  8. typedef shm_name_t jack_shm_id_t;
  9. #else
  10. typedef int jack_shm_id_t;
  11. #endif /* !USE_POSIX_SHM */
  12. typedef int16_t jack_shm_registry_index_t;
  13. /**
  14. * A structure holding information about shared memory
  15. * allocated by JACK. this version persists across
  16. * invocations of JACK, and can be used by multiple
  17. * JACK servers. It contains no pointers and is valid
  18. * across address spaces.
  19. */
  20. typedef struct _jack_shm_registry {
  21. pid_t allocator; /* PID that created shm segment */
  22. jack_shmsize_t size; /* needed for POSIX unattach */
  23. jack_shm_registry_index_t index; /* offset into the registry */
  24. jack_shm_id_t id; /* API specific, see above */
  25. } jack_shm_registry_t;
  26. /**
  27. * a structure holding information about shared memory
  28. * allocated by JACK. this version is valid only
  29. * for a given address space. It contains a pointer
  30. * indicating where the shared memory has been
  31. * attached to the address space.
  32. */
  33. typedef struct _jack_shm_info {
  34. jack_shm_registry_index_t index; /* offset into the registry */
  35. char* attached_at; /* address where attached */
  36. } jack_shm_info_t;
  37. /* utility functions used only within JACK */
  38. extern void jack_shm_copy_from_registry (jack_shm_info_t*,
  39. jack_shm_registry_index_t);
  40. extern void jack_shm_copy_to_registry (jack_shm_info_t*,
  41. jack_shm_registry_index_t*);
  42. extern void jack_release_shm_info (jack_shm_registry_index_t);
  43. static inline char* jack_shm_addr (jack_shm_info_t* si) {
  44. return si->attached_at;
  45. }
  46. /* here beginneth the API */
  47. extern int jack_initialize_shm (void);
  48. extern void jack_cleanup_shm (void);
  49. extern int jack_shmalloc (const char *shm_name, jack_shmsize_t size, jack_shm_info_t* result);
  50. extern void jack_release_shm (jack_shm_info_t*);
  51. extern void jack_destroy_shm (jack_shm_info_t*);
  52. extern int jack_attach_shm (jack_shm_info_t*);
  53. extern int jack_resize_shm (jack_shm_info_t*, jack_shmsize_t size);
  54. #endif /* __jack_shm_h__ */