mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-25 12:33:42 +01:00
Rename and share `ALIGN' macro from _UCD_internal.h
Rename the `ALIGN' macro to `UNW_ALIGN', and move it from `_UCD_internal.h' to `libunwind_i.h' so that we can share it with the mempool code. `ALIGN' was clashing with system headers on FreeBSD: In file included from src/coredump/_UCD_access_reg_freebsd.c:26: src/coredump/_UCD_internal.h:102:1: warning: "ALIGN" redefined In file included from /usr/include/sys/param.h:115, from src/coredump/_UCD_lib.h:52, from src/coredump/_UCD_access_reg_freebsd.c:24: /usr/include/machine/param.h:79:1: warning: this is the location of the previous definition
This commit is contained in:
parent
ee06b32975
commit
c2f7574187
4 changed files with 9 additions and 8 deletions
|
@ -352,4 +352,6 @@ static inline void invalidate_edi (struct elf_dyn_info *edi)
|
|||
# define tdep_get_func_addr(as,addr,v) (*(v) = addr, 0)
|
||||
#endif
|
||||
|
||||
#define UNW_ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
|
||||
|
||||
#endif /* libunwind_i_h */
|
||||
|
|
|
@ -66,8 +66,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|||
#include "_UCD_lib.h"
|
||||
#include "_UCD_internal.h"
|
||||
|
||||
#define NOTE_DATA(_hdr) STRUCT_MEMBER_P((_hdr), sizeof (Elf32_Nhdr) + ALIGN((_hdr)->n_namesz, 4))
|
||||
#define NOTE_SIZE(_hdr) (sizeof (Elf32_Nhdr) + ALIGN((_hdr)->n_namesz, 4) + (_hdr)->n_descsz)
|
||||
#define NOTE_DATA(_hdr) STRUCT_MEMBER_P((_hdr), sizeof (Elf32_Nhdr) + UNW_ALIGN((_hdr)->n_namesz, 4))
|
||||
#define NOTE_SIZE(_hdr) (sizeof (Elf32_Nhdr) + UNW_ALIGN((_hdr)->n_namesz, 4) + (_hdr)->n_descsz)
|
||||
#define NOTE_NEXT(_hdr) STRUCT_MEMBER_P((_hdr), NOTE_SIZE(_hdr))
|
||||
#define NOTE_FITS_IN(_hdr, _size) ((_size) >= sizeof (Elf32_Nhdr) && (_size) >= NOTE_SIZE (_hdr))
|
||||
#define NOTE_FITS(_hdr, _end) NOTE_FITS_IN((_hdr), (unsigned long)((char *)(_end) - (char *)(_hdr)))
|
||||
|
|
|
@ -99,7 +99,6 @@ struct UCD_info
|
|||
|
||||
extern coredump_phdr_t * _UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip);
|
||||
|
||||
#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
|
||||
#define STRUCT_MEMBER_P(struct_p, struct_offset) ((void *) ((char*) (struct_p) + (long) (struct_offset)))
|
||||
#define STRUCT_MEMBER(member_type, struct_p, struct_offset) (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset)))
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ sos_alloc (size_t size)
|
|||
#ifdef HAVE_CMPXCHG
|
||||
char *old_mem;
|
||||
|
||||
size = (size + MAX_ALIGN - 1) & -MAX_ALIGN;
|
||||
size = UNW_ALIGN(size, MAX_ALIGN);
|
||||
if (!sos_memp)
|
||||
cmpxchg_ptr (&sos_memp, 0, sos_memory);
|
||||
do
|
||||
{
|
||||
old_mem = sos_memp;
|
||||
|
||||
mem = (char *) (((unsigned long) old_mem + MAX_ALIGN - 1) & -MAX_ALIGN);
|
||||
mem = (char *) UNW_ALIGN((unsigned long) old_mem, MAX_ALIGN);
|
||||
mem += size;
|
||||
assert (mem < sos_memory + sizeof (sos_memory));
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ sos_alloc (size_t size)
|
|||
static define_lock (sos_lock);
|
||||
intrmask_t saved_mask;
|
||||
|
||||
size = (size + MAX_ALIGN - 1) & -MAX_ALIGN;
|
||||
size = UNW_ALIGN(size, MAX_ALIGN);
|
||||
|
||||
lock_acquire (&sos_lock, saved_mask);
|
||||
{
|
||||
if (!sos_memp)
|
||||
sos_memp = sos_memory;
|
||||
|
||||
mem = (char *) (((unsigned long) sos_memp + MAX_ALIGN - 1) & -MAX_ALIGN);
|
||||
mem = (char *) UNW_ALIGN((unsigned long) sos_memp, MAX_ALIGN);
|
||||
mem += size;
|
||||
assert (mem < sos_memory + sizeof (sos_memory));
|
||||
sos_memp = mem;
|
||||
|
@ -126,7 +126,7 @@ mempool_init (struct mempool *pool, size_t obj_size, size_t reserve)
|
|||
lock_init (&pool->lock);
|
||||
|
||||
/* round object-size up to integer multiple of MAX_ALIGN */
|
||||
obj_size = (obj_size + MAX_ALIGN - 1) & -MAX_ALIGN;
|
||||
obj_size = UNW_ALIGN(obj_size, MAX_ALIGN);
|
||||
|
||||
if (!reserve)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue