Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tammo Jan Dijkema
dt_ctrl
Commits
7442da75
Commit
7442da75
authored
Feb 27, 2013
by
Jeroen Vreeken
Browse files
Add ARM EABI defines to the va_list macros.
These are not yet tested (due to lack of ARM compiler)
parent
847f1981
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/include/dynarg.h
View file @
7442da75
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2013
Copyright Stichting C.A. Muller Radioastronomiestation, 2013
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _INCLUDE_DYNARG_H_
#define _INCLUDE_DYNARG_H_
#include
<stdarg.h>
#include
<malloc.h>
#ifdef __x86_64__
#if defined(__x86_64__)
#include
<string.h>
...
...
@@ -66,7 +86,10 @@ do { \
#else
/* __x86_64__*/
/* endif __x86_64__ */
#elif defined(__i386__)
...
...
@@ -94,6 +117,44 @@ do { \
#define va_free(list) free(((char *)(list)) - sizeof(char *))
#endif
/* __x86_64__ */
/* endif __i386__ */
#elif defined(__arm__) && defined(__ARM_EABI__)
#define va_new(list) \
do { \
char *ptr = malloc(sizeof(char *)) + sizeof(char *)*2; \
(list).__ap = ptr; \
((char **)ptr)[-1] = ptr; \
} while (0)
#define va_add(list, type, val) \
do { \
char *ptr; \
char **clist = (char **)(list).__ap; \
type tmpval = val; \
size_t size, fill; \
\
size = ((size_t)clist[-1] - (size_t)(clist)); \
if ((size & 0x7) && !(sizeof(type) & 0x7)) \
fill = 4; \
else \
fill = 0; \
clist = realloc(&clist[-2], \
size + fill + sizeof(type) + sizeof(char *)*2) + sizeof(char *)*2; \
(list).__ap = (void *)clist; \
ptr = ((char *)clist + size); \
ptr += fill; \
memcpy(ptr, &tmpval, sizeof(tmpval)); \
clist[-1] = ptr + sizeof(type); \
} while (0)
#define va_free(list) free(((char *)(list).__ap) - sizeof(char *)*2)
#endif
/* defined(__arm__) && defined(__ARM_EABI__) */
#endif
/* _INCLUDE_DYNARG_H_ */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment