From 0b3b3b38bda8ad7879da316a10f4e90a07a93cca Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 29 Jan 2012 23:27:31 +0100 Subject: [PATCH] * grub-core/lib/posix_wrap/limits.h (SHRT_MAX): New define. (INT_MAX): Likewise. * grub-core/lib/posix_wrap/stdio.h (snprintf): New function. * grub-core/lib/posix_wrap/stdlib.h (abs): Likewise. * grub-core/lib/posix_wrap/string.h (memcmp): Likewise. (strcpy): Likewise. (strstr): Likewise. (strchr): Likewise. (strncpy): Likewise. (strcat): Likewise. (strncat): Likewise. (strcoll): Likewise. * include/grub/types.h (GRUB_SHRT_MAX): New define. (GRUB_INT_MAX): Likewise. --- ChangeLog | 17 +++++++++++ grub-core/lib/posix_wrap/limits.h | 3 ++ grub-core/lib/posix_wrap/stdio.h | 13 ++++++++ grub-core/lib/posix_wrap/stdlib.h | 6 ++++ grub-core/lib/posix_wrap/string.h | 51 ++++++++++++++++++++++++++++++- include/grub/types.h | 2 ++ 6 files changed, 91 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 943c43372..4ff81bbeb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2012-01-29 Vladimir Serbinenko + + * grub-core/lib/posix_wrap/limits.h (SHRT_MAX): New define. + (INT_MAX): Likewise. + * grub-core/lib/posix_wrap/stdio.h (snprintf): New function. + * grub-core/lib/posix_wrap/stdlib.h (abs): Likewise. + * grub-core/lib/posix_wrap/string.h (memcmp): Likewise. + (strcpy): Likewise. + (strstr): Likewise. + (strchr): Likewise. + (strncpy): Likewise. + (strcat): Likewise. + (strncat): Likewise. + (strcoll): Likewise. + * include/grub/types.h (GRUB_SHRT_MAX): New define. + (GRUB_INT_MAX): Likewise. + 2012-01-29 Vladimir Serbinenko * grub-core/gnulib/regcomp.c (regerror): Don't use abort on diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h index fe8523e68..588e5899a 100644 --- a/grub-core/lib/posix_wrap/limits.h +++ b/grub-core/lib/posix_wrap/limits.h @@ -26,6 +26,9 @@ #define UINT_MAX GRUB_UINT_MAX #define ULONG_MAX GRUB_ULONG_MAX +#define SHRT_MAX GRUB_SHRT_MAX +#define INT_MAX GRUB_INT_MAX + #define CHAR_BIT 8 #endif diff --git a/grub-core/lib/posix_wrap/stdio.h b/grub-core/lib/posix_wrap/stdio.h index 701fceaa4..e6b1178c5 100644 --- a/grub-core/lib/posix_wrap/stdio.h +++ b/grub-core/lib/posix_wrap/stdio.h @@ -26,4 +26,17 @@ typedef struct grub_file FILE; #define EOF -1 +static inline int +snprintf (char *str, size_t n, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start (ap, fmt); + ret = grub_vsnprintf (str, n, fmt, ap); + va_end (ap); + + return ret; +} + #endif diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h index 31fe055a7..3b46f47ff 100644 --- a/grub-core/lib/posix_wrap/stdlib.h +++ b/grub-core/lib/posix_wrap/stdlib.h @@ -46,4 +46,10 @@ realloc (void *ptr, grub_size_t size) return grub_realloc (ptr, size); } +static inline int +abs (int c) +{ + return (c >= 0) ? c : -c; +} + #endif diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h index f38c97ba4..7e18b1a04 100644 --- a/grub-core/lib/posix_wrap/string.h +++ b/grub-core/lib/posix_wrap/string.h @@ -45,6 +45,55 @@ memcpy (void *dest, const void *src, grub_size_t n) { return grub_memcpy (dest, src, n); } -#endif + +static inline int +memcmp (const void *s1, const void *s2, size_t n) +{ + return grub_memcmp (s1, s2, n); +} + +#endif + +static inline char * +strcpy (char *dest, const char *src) +{ + return grub_strcpy (dest, src); +} + +static inline char * +strstr (const char *haystack, const char *needle) +{ + return grub_strstr (haystack, needle); +} + +static inline char * +strchr (const char *s, int c) +{ + return grub_strchr (s, c); +} + +static inline char * +strncpy (char *dest, const char *src, size_t n) +{ + return grub_strncpy (dest, src, n); +} + +static inline char * +strcat (char *dest, const char *src) +{ + return grub_strcat (dest, src); +} + +static inline char * +strncat (char *dest, const char *src, size_t n) +{ + return grub_strncat (dest, src, n); +} + +static inline int +strcoll (const char *s1, const char *s2) +{ + return grub_strcmp (s1, s2); +} #endif diff --git a/include/grub/types.h b/include/grub/types.h index 89c1697d2..94badaa1d 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -121,7 +121,9 @@ typedef grub_int32_t grub_ssize_t; #define GRUB_UCHAR_MAX 0xFF #define GRUB_USHRT_MAX 65535 +#define GRUB_SHRT_MAX 0x7fff #define GRUB_UINT_MAX 4294967295U +#define GRUB_INT_MAX 0x7fffffff #if GRUB_CPU_SIZEOF_LONG == 8 # define GRUB_ULONG_MAX 18446744073709551615UL