bessaconstr: Avoid duplicate map lookups.
[libfirm] / ir / lpp / lpp_comm.h
index 5d03f1a..193d004 100644 (file)
@@ -1,71 +1,70 @@
-/**
- * @file   lpp_server.h
- * @date   19.07.2005
- * @author Sebastian Hack
+/*
+ * Copyright (C) 2005-2011 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
  *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
-#ifndef _LPP_COMM_H
-#define _LPP_COMM_H
+/**
+ * @file
+ * @author  Sebastian Hack
+ */
+#ifndef LPP_LPP_COMM_H
+#define LPP_LPP_COMM_H
 
 #include <stdio.h>
 #include <stdarg.h>
-
-#ifdef _MSC_VER
-
-typedef size_t              ssize_t;
-typedef unsigned __int16    uint16_t;
-typedef unsigned __int32    uint32_t;
-
-/* 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 )
-
-#else /* _MSC_VER */
-
 #include <stdint.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netinet/in.h>
-
-#endif /* _MSC_VER */
-
-
 
 #define LPP_PORT    2175
 #define LPP_BUFSIZE (1 << 20)
 
 enum {
-#define LPP_CMD(x) LPP_CMD_ ## x,
-#include "lpp_cmd.def"
-#undef LPP_CMD
-  LPP_CMD_LAST
+       LPP_CMD_BAD,
+       LPP_CMD_OK,
+       LPP_CMD_PROBLEM,
+       LPP_CMD_SOLUTION,
+       LPP_CMD_SOLVER,
+       LPP_CMD_BYE,
+       LPP_CMD_SOLVERS,
+       LPP_CMD_SET_DEBUG,
+       LPP_CMD_INFO,
+       LPP_CMD_LAST
 };
 
 #define BASIC_ERR_CHECK(expr,op,cond,fmt,last) \
-{ \
-  int res; \
-  if((res = (expr)) op cond) { \
+do { \
+  int err_check_res; \
+  if((err_check_res = (expr)) op cond) { \
     fprintf(stderr, "%s(%u): %d = %s(%d): ", \
-        __FILE__, (unsigned) __LINE__, res, #expr, cond); \
+        __FILE__, (unsigned) __LINE__, err_check_res, #expr, cond); \
     lpp_print_err fmt; \
     fprintf(stderr, "\n"); \
     last; \
   } \
-}
+} while(0)
 
 #define BASIC_ERRNO_CHECK(expr,op,cond,last) \
-{ \
+do { \
   int _basic_errno_check_res = (expr); \
   if(_basic_errno_check_res op cond) { \
     fprintf(stderr, "%s(%u): %d = %s(%d): %s\n", \
         __FILE__, (unsigned) __LINE__, _basic_errno_check_res, #expr, (int) cond, strerror(errno)); \
     last; \
   } \
-}
+} while(0)
 
 #define ERR_CHECK_RETURN(expr, op, cond, fmt, retval) \
   BASIC_ERR_CHECK(expr, op, cond, fmt, return retval)
@@ -91,7 +90,7 @@ lpp_comm_t *lpp_comm_new(int fd, size_t buf_size);
 
 int lpp_comm_fileno(const lpp_comm_t *comm);
 
-ssize_t lpp_flush(lpp_comm_t *comm);
+void lpp_flush(lpp_comm_t *comm);
 
 void lpp_comm_free(lpp_comm_t *comm);
 
@@ -121,4 +120,4 @@ void lpp_send_ack(lpp_comm_t *comm);
 
 const char *lpp_get_cmd_name(int cmd);
 
-#endif /* _LPP_COMM_H */
+#endif