1*743Smax.romanov@nginx.com 2*743Smax.romanov@nginx.com /* 3*743Smax.romanov@nginx.com * Copyright (C) NGINX, Inc. 4*743Smax.romanov@nginx.com */ 5*743Smax.romanov@nginx.com 6*743Smax.romanov@nginx.com #ifndef _NXT_UNIT_SPTR_H_INCLUDED_ 7*743Smax.romanov@nginx.com #define _NXT_UNIT_SPTR_H_INCLUDED_ 8*743Smax.romanov@nginx.com 9*743Smax.romanov@nginx.com 10*743Smax.romanov@nginx.com #include <inttypes.h> 11*743Smax.romanov@nginx.com #include <stddef.h> 12*743Smax.romanov@nginx.com #include <string.h> 13*743Smax.romanov@nginx.com 14*743Smax.romanov@nginx.com #include "nxt_unit_typedefs.h" 15*743Smax.romanov@nginx.com 16*743Smax.romanov@nginx.com 17*743Smax.romanov@nginx.com /* Serialized pointer. */ 18*743Smax.romanov@nginx.com union nxt_unit_sptr_u { 19*743Smax.romanov@nginx.com uint8_t base[1]; 20*743Smax.romanov@nginx.com uint32_t offset; 21*743Smax.romanov@nginx.com }; 22*743Smax.romanov@nginx.com 23*743Smax.romanov@nginx.com 24*743Smax.romanov@nginx.com static inline void nxt_unit_sptr_set(nxt_unit_sptr_t * sptr,void * ptr)25*743Smax.romanov@nginx.comnxt_unit_sptr_set(nxt_unit_sptr_t *sptr, void *ptr) 26*743Smax.romanov@nginx.com { 27*743Smax.romanov@nginx.com sptr->offset = (uint8_t *) ptr - sptr->base; 28*743Smax.romanov@nginx.com } 29*743Smax.romanov@nginx.com 30*743Smax.romanov@nginx.com 31*743Smax.romanov@nginx.com static inline void * nxt_unit_sptr_get(nxt_unit_sptr_t * sptr)32*743Smax.romanov@nginx.comnxt_unit_sptr_get(nxt_unit_sptr_t *sptr) 33*743Smax.romanov@nginx.com { 34*743Smax.romanov@nginx.com return sptr->base + sptr->offset; 35*743Smax.romanov@nginx.com } 36*743Smax.romanov@nginx.com 37*743Smax.romanov@nginx.com 38*743Smax.romanov@nginx.com #endif /* _NXT_UNIT_SPTR_H_INCLUDED_ */ 39