summaryrefslogtreecommitdiffhomepage
path: root/ir/libcore
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-10-20 19:08:00 +0200
committerMatthias Braun <matze@braunis.de>2011-10-20 19:32:26 +0200
commit594a8d1e36bc3b3d4b33684d2b1d20453551035f (patch)
treee0a99e4456e91fd65adfacb18a1b8419c1d06513 /ir/libcore
parent2e179fbd54125606903fc7e438d02a6d3aacc6eb (diff)
remove unnecessary libcore bits
Diffstat (limited to 'ir/libcore')
-rw-r--r--ir/libcore/lc_appendable.c4
-rw-r--r--ir/libcore/lc_config.h80
-rw-r--r--ir/libcore/lc_defines.h39
-rw-r--r--ir/libcore/lc_opts.c3
-rw-r--r--ir/libcore/lc_opts_t.h2
-rw-r--r--ir/libcore/lc_printf.c10
-rw-r--r--ir/libcore/lc_printf.h12
-rw-r--r--ir/libcore/lc_printf_arg_types.def4
8 files changed, 15 insertions, 139 deletions
diff --git a/ir/libcore/lc_appendable.c b/ir/libcore/lc_appendable.c
index ed27d63..f62aa6b 100644
--- a/ir/libcore/lc_appendable.c
+++ b/ir/libcore/lc_appendable.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <string.h>
-#include "lc_defines.h"
+#include "util.h"
#include "lc_printf.h"
/* Default appendable implementations */
@@ -109,7 +109,7 @@ static void str_init(lc_appendable_t *obj)
static int str_snadd(lc_appendable_t *obj, const char *str, size_t n)
{
- size_t to_write = LC_MIN(obj->limit - obj->written - 1, n);
+ size_t to_write = MIN(obj->limit - obj->written - 1, n);
char *tgt = (char*)obj->obj;
strncpy(tgt + obj->written, str, to_write);
obj->written += to_write;
diff --git a/ir/libcore/lc_config.h b/ir/libcore/lc_config.h
deleted file mode 100644
index 2ccf020..0000000
--- a/ir/libcore/lc_config.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- libcore: library for basic data structures and algorithms.
- Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-/**
- * Central definitions for the libcore.
- * @author Sebastian Hack
- * @date 22.12.2004
- */
-#ifndef _LC_CONFIG_H
-#define _LC_CONFIG_H
-
-#if defined(__GNUC__)
-
-#define inline __inline__
-#define LC_FUNCNAME __FUNCTION__
-#define LC_PRINTF(m) __attribute__((format(printf,m,(m)+1)))
-
-#ifdef __STRICT_ANSI__
-#define LC_LONGLONG long
-#define LC_LONGDOUBLE double
-#else
-#define LC_LONGLONG long long
-#define LC_LONGDOUBLE long double
-#endif
-
-#elif defined(_MSC_VER)
-
-#define LC_FUNCNAME "<unknown>"
-#define LC_PRINTF(m)
-
-#define LC_LONGLONG __int64
-#define LC_LONGDOUBLE long double
-
-/* disable warning: 'foo' was declared deprecated, use 'bla' instead */
-/* of course MS had to make 'bla' incompatible to 'foo', so a simple */
-/* define will not work :-((( */
-#pragma warning( disable : 4996 )
-
-#ifdef _WIN32
-#define snprintf _snprintf
-#endif /* _WIN32 */
-
-#if _MSC_VER <= 1200
-typedef __int16 int16;
-typedef __int32 int32;
-typedef __int64 int64;
-typedef unsigned __int16 uint16;
-typedef unsigned __int32 uint32;
-typedef unsigned __int64 uint64;
-#endif /* _MSC_VER <= 1200 */
-
-/* default definitions */
-#else /* !defined(__GNUC__) && !defined(_MSC_VER) */
-
-#define inline
-#define LC_FUNCNAME "<unknown>"
-#define LC_LONGLONG long
-#define LC_LONGDOUBLE double
-#define LC_PRINTF(m)
-
-#endif
-
-#endif /* _LC_CONFIG_H */
diff --git a/ir/libcore/lc_defines.h b/ir/libcore/lc_defines.h
deleted file mode 100644
index eef6fe2..0000000
--- a/ir/libcore/lc_defines.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- libcore: library for basic data structures and algorithms.
- Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-/**
- * Some common defines.
- * @author Sebastian Hack
- * @date 22.12.2004
- */
-
-#ifndef _LIBCORE_DEFINES_H
-#define _LIBCORE_DEFINES_H
-
-#define LC_ARRSIZE(x) (sizeof(x) / sizeof(x[0]))
-
-#define LC_MIN(x,y) ((x) < (y) ? (x) : (y))
-#define LC_MAX(x,y) ((x) > (y) ? (x) : (y))
-
-/** define a readable fourcc code */
-#define LC_FOURCC(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
-#define LC_FOURCC_STR(str) LC_FOURCC(str[0], str[1], str[2], str[3])
-
-#endif
diff --git a/ir/libcore/lc_opts.c b/ir/libcore/lc_opts.c
index 3c33724..665398a 100644
--- a/ir/libcore/lc_opts.c
+++ b/ir/libcore/lc_opts.c
@@ -28,6 +28,7 @@
#include "lc_opts_enum.h"
#include "hashptr.h"
#include "lc_printf.h"
+#include "util.h"
#include "xmalloc.h"
#include "obst.h"
@@ -504,7 +505,7 @@ int lc_opt_occurs(lc_opt_entry_t *opt, const char *value, lc_opt_err_info_t *err
case lc_opt_type_bit:
case lc_opt_type_negbit:
strtolower(buf, sizeof(buf), value);
- for (i = 0; i < LC_ARRSIZE(bool_strings); ++i) {
+ for (i = 0; i < ARRAY_SIZE(bool_strings); ++i) {
if (strcmp(buf, bool_strings[i].str) == 0) {
val->integer = bool_strings[i].val;
error = lc_opt_err_none;
diff --git a/ir/libcore/lc_opts_t.h b/ir/libcore/lc_opts_t.h
index 46f6d46..61c683e 100644
--- a/ir/libcore/lc_opts_t.h
+++ b/ir/libcore/lc_opts_t.h
@@ -27,8 +27,6 @@
#include "lc_opts.h"
#include "list.h"
-#include "lc_defines.h"
-
typedef struct {
struct list_head opts;
struct list_head grps;
diff --git a/ir/libcore/lc_printf.c b/ir/libcore/lc_printf.c
index 2e6cedf..6ea8d31 100644
--- a/ir/libcore/lc_printf.c
+++ b/ir/libcore/lc_printf.c
@@ -35,8 +35,8 @@
#include "xmalloc.h"
#include "lc_printf.h"
-#include "lc_defines.h"
#include "hashptr.h"
+#include "util.h"
#include "set.h"
/* printf implementation */
@@ -136,7 +136,7 @@ int lc_arg_append(lc_appendable_t *app, const lc_arg_occ_t *occ, const char *str
if (!occ->flag_minus && occ->flag_zero)
pad = '0';
- return lc_appendable_snwadd(app, str, len, LC_MAX(0, occ->width), occ->flag_minus, pad);
+ return lc_appendable_snwadd(app, str, len, MAX(0, occ->width), occ->flag_minus, pad);
}
@@ -172,7 +172,7 @@ static char *make_fmt(char *buf, size_t len, const lc_arg_occ_t *occ)
assert(occ->modifier && "modifier must not be NULL");
strncpy(mod, occ->modifier, sizeof(mod) - 1);
- mod[LC_MIN(sizeof(mod) - 1, occ->modifier_length)] = '\0';
+ mod[MIN(sizeof(mod) - 1, occ->modifier_length)] = '\0';
#ifdef _MSC_VER
/* work-around for buggy mscrt not supporting z, j, and t modifier */
@@ -297,7 +297,7 @@ static int std_emit(lc_appendable_t *app, const lc_arg_occ_t *occ, const lc_arg_
default:
{
- int len = LC_MAX(128, occ->width + 1);
+ int len = MAX(128, occ->width + 1);
char *buf = XMALLOCN(char, len);
res = dispatch_snprintf(buf, len, fmt, occ->lc_arg_type, val);
res = lc_appendable_snadd(app, buf, res);
@@ -405,7 +405,7 @@ int lc_evpprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt,
/* Negative or lacking precision after a '.' is treated as
* precision 0. */
- occ.precision = LC_MAX(0, precision);
+ occ.precision = MAX(0, precision);
}
/*
diff --git a/ir/libcore/lc_printf.h b/ir/libcore/lc_printf.h
index 558b09a..ca8169c 100644
--- a/ir/libcore/lc_printf.h
+++ b/ir/libcore/lc_printf.h
@@ -17,14 +17,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
/**
* Flexible printf().
* @author Sebastian Hack
* @date 3.1.2005
*/
-
#ifndef _LIBCORE_LC_PRINTF_H
#define _LIBCORE_LC_PRINTF_H
@@ -35,7 +32,6 @@
#include <obstack.h>
-#include "lc_config.h"
#include "lc_appendable.h"
typedef struct lc_arg_occ_t {
@@ -111,10 +107,10 @@ int lc_evsnprintf(const lc_arg_env_t *env, char *buf, size_t len, const char *fm
int lc_evfprintf(const lc_arg_env_t *env, FILE *f, const char *fmt, va_list args);
int lc_evoprintf(const lc_arg_env_t *env, struct obstack *obst, const char *fmt, va_list args);
-int lc_printf(const char *fmt, ...) LC_PRINTF(1);
-int lc_snprintf(char *buf, size_t len, const char *fmt, ...) LC_PRINTF(3);
-int lc_fprintf(FILE *f, const char *fmt, ...) LC_PRINTF(2);
-int lc_oprintf(struct obstack *obst, const char *fmt, ...) LC_PRINTF(2);
+int lc_printf(const char *fmt, ...);
+int lc_snprintf(char *buf, size_t len, const char *fmt, ...);
+int lc_fprintf(FILE *f, const char *fmt, ...);
+int lc_oprintf(struct obstack *obst, const char *fmt, ...);
int lc_vprintf(const char *fmt, va_list args);
int lc_vsnprintf(char *buf, size_t len, const char *fmt, va_list args);
diff --git a/ir/libcore/lc_printf_arg_types.def b/ir/libcore/lc_printf_arg_types.def
index ccfa5da..48d957a 100644
--- a/ir/libcore/lc_printf_arg_types.def
+++ b/ir/libcore/lc_printf_arg_types.def
@@ -3,9 +3,9 @@ LC_ARG_TYPE(char, char, int)
LC_ARG_TYPE(short, short, int)
LC_ARG_TYPE(int, int, int)
LC_ARG_TYPE(long, long, long)
-LC_ARG_TYPE(LC_LONGLONG, long_long, LC_LONGLONG)
+LC_ARG_TYPE(long long, long_long, long long)
LC_ARG_TYPE(double, double, double)
-LC_ARG_TYPE(LC_LONGDOUBLE, long_double, LC_LONGDOUBLE)
+LC_ARG_TYPE(long double, long_double, long double)
LC_ARG_TYPE(void *, ptr, void *)
LC_ARG_TYPE(intmax_t, intmax_t, intmax_t)
LC_ARG_TYPE(ptrdiff_t, ptrdiff_t, ptrdiff_t)