Skip to content

Commit

Permalink
lib/atoi/a2i/: Simplify these macros by calling a2i()
Browse files Browse the repository at this point in the history
I applied a similar patch in liba2i, where I've tested it.

Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Dec 17, 2024
1 parent 8821d3f commit 4048fbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 86 deletions.
50 changes: 7 additions & 43 deletions lib/atoi/a2i/a2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,13 @@

#include <config.h>

#include "atoi/a2i/a2s_c.h"
#include "atoi/a2i/a2s_nc.h"


#define a2sh(n, s, ...) \
( \
_Generic(s, \
const char *: a2sh_c, \
const void *: a2sh_c, \
char *: a2sh_nc, \
void *: a2sh_nc \
)(n, s, __VA_ARGS__) \
)

#define a2si(n, s, ...) \
( \
_Generic(s, \
const char *: a2si_c, \
const void *: a2si_c, \
char *: a2si_nc, \
void *: a2si_nc \
)(n, s, __VA_ARGS__) \
)

#define a2sl(n, s, ...) \
( \
_Generic(s, \
const char *: a2sl_c, \
const void *: a2sl_c, \
char *: a2sl_nc, \
void *: a2sl_nc \
)(n, s, __VA_ARGS__) \
)

#define a2sll(n, s, ...) \
( \
_Generic(s, \
const char *: a2sll_c, \
const void *: a2sll_c, \
char *: a2sll_nc, \
void *: a2sll_nc \
)(n, s, __VA_ARGS__) \
)
#include "atoi/a2i/a2i.h"


#define a2sh(...) a2i(short, __VA_ARGS__)
#define a2si(...) a2i(int, __VA_ARGS__)
#define a2sl(...) a2i(long, __VA_ARGS__)
#define a2sll(...) a2i(long long, __VA_ARGS__)


#endif // include guard
50 changes: 7 additions & 43 deletions lib/atoi/a2i/a2u.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,13 @@

#include <config.h>

#include "atoi/a2i/a2u_c.h"
#include "atoi/a2i/a2u_nc.h"


#define a2uh(n, s, ...) \
( \
_Generic(s, \
const char *: a2uh_c, \
const void *: a2uh_c, \
char *: a2uh_nc, \
void *: a2uh_nc \
)(n, s, __VA_ARGS__) \
)

#define a2ui(n, s, ...) \
( \
_Generic(s, \
const char *: a2ui_c, \
const void *: a2ui_c, \
char *: a2ui_nc, \
void *: a2ui_nc \
)(n, s, __VA_ARGS__) \
)

#define a2ul(n, s, ...) \
( \
_Generic(s, \
const char *: a2ul_c, \
const void *: a2ul_c, \
char *: a2ul_nc, \
void *: a2ul_nc \
)(n, s, __VA_ARGS__) \
)

#define a2ull(n, s, ...) \
( \
_Generic(s, \
const char *: a2ull_c, \
const void *: a2ull_c, \
char *: a2ull_nc, \
void *: a2ull_nc \
)(n, s, __VA_ARGS__) \
)
#include "atoi/a2i/a2i.h"


#define a2uh(...) a2i(unsigned short, __VA_ARGS__)
#define a2ui(...) a2i(unsigned int, __VA_ARGS__)
#define a2ul(...) a2i(unsigned long, __VA_ARGS__)
#define a2ull(...) a2i(unsigned long long, __VA_ARGS__)


#endif // include guard

0 comments on commit 4048fbc

Please sign in to comment.