From fe6781a9899df7eb7c2d950e4269b7c068b17024 Mon Sep 17 00:00:00 2001 From: Fike Etki Date: Wed, 12 Mar 2014 14:53:49 -0400 Subject: [PATCH 1/3] Cleaned up leftover #ifdef A right after #define A --- KPHP/compiler/bicycle.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/KPHP/compiler/bicycle.cpp b/KPHP/compiler/bicycle.cpp index 7cf972a..d43395e 100644 --- a/KPHP/compiler/bicycle.cpp +++ b/KPHP/compiler/bicycle.cpp @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with VK/KittenPHP-DB-Engine. If not, see . - This program is released under the GPL with the additional exemption + This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed. You are free to remove this exemption from derived works. @@ -32,7 +32,6 @@ __thread int bicycle_thread_id; /*** Malloc hooks ***/ #define BICYCLE_MALLOC -#ifdef BICYCLE_MALLOC extern "C" { extern __typeof (malloc) __libc_malloc; extern __typeof (free) __libc_free; @@ -147,7 +146,6 @@ void free (void *ptr) { return zallocator->free (ptr); } } -#endif int get_thread_id() { return bicycle_thread_id; From 640af38fbc5298fb0f08fcfa5619f29514553362 Mon Sep 17 00:00:00 2001 From: Fike Etki Date: Wed, 12 Mar 2014 14:55:47 -0400 Subject: [PATCH 2/3] Just a stupid rewrite of code-generating script --- copyexec/copyexec-err.py | 71 +++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 27 deletions(-) mode change 100644 => 100755 copyexec/copyexec-err.py diff --git a/copyexec/copyexec-err.py b/copyexec/copyexec-err.py old mode 100644 new mode 100755 index c49f2a0..be7d57f --- a/copyexec/copyexec-err.py +++ b/copyexec/copyexec-err.py @@ -1,36 +1,53 @@ #!/usr/bin/python import sys, os -def header (f): - f.write ('/* Generated by python script */\n') +class SuperFile: + def __init__(self, name): + self.path = os.path.join(sys.path[0], name + '-test') + self.lines = ['/* Generated by python script */'] + def __enter__(self): + return self + def __exit__(self, type, value, traceback): + with open(self.path, 'w') as f: + f.write('\n'.join(self.lines) + '\n') + def append(self, line): + self.lines.append(line) -errors = ['LSEEK', 'READ', 'CRC32', 'TYPE', 'DECRYPT', 'MALLOC', 'ALIGN', 'SIZE', 'SHA1', 'MKDIR', 'OPEN', 'FSTAT'] -errors += ['ST_DEV', 'ST_INO', 'READIN', 'STATUS', 'FORK', 'CHDIR', 'CREAT', 'STAT', 'PUBKEY_PERMISSIONS'] +errors = [ + 'LSEEK', 'READ', 'CRC32', 'TYPE', 'DECRYPT', 'MALLOC', 'ALIGN', 'SIZE', + 'SHA1', 'MKDIR', 'OPEN', 'FSTAT' +] +errors += [ + 'ST_DEV', 'ST_INO', 'READIN', 'STATUS', 'FORK', 'CHDIR', 'CREAT', 'STAT', + 'PUBKEY_PERMISSIONS' +] errors += ['INVAL'] ########### copyexec-results errors ########### -errors += ['VOLUME_ID_MISMATCHED', 'HOSTNAME_MISMATCHED', 'DISCONNECT', 'OLD_RESULT'] +errors += [ + 'VOLUME_ID_MISMATCHED', 'HOSTNAME_MISMATCHED', 'DISCONNECT', 'OLD_RESULT' +] -e = [(s, -(i+1)) for i, s in enumerate (errors)] -e.append (('UNKNOWN', -999)) +errors = [(s, -(i+1)) for i, s in enumerate (errors)] +errors.append (('UNKNOWN', -999)) -f = open (os.path.join (sys.path[0], 'copyexec-err.h'), 'w') -header (f) -for s, i in e: - f.write ('#define COPYEXEC_ERR_' + s + ' (' + str (i) + ')\n') -f.write ('char *copyexec_strerror (int err);\n') -f.close () -f = open (os.path.join (sys.path[0], 'copyexec-err.c'), 'w') -header (f) -f.write ('#include \n') -f.write ('#include \n') -f.write ('#include "copyexec-err.h"\n') -f.write ('char *copyexec_strerror (int err) {\n') -f.write (' static char buf[64];') -f.write (' switch (err) {\n') -for s, i in e: - f.write (' case COPYEXEC_ERR_' + s + ': return "COPYEXEC_ERR_' + s + '"; break;\n') -f.write (' default: assert (snprintf (buf, sizeof (buf), "COPYEXEC_ERR_UNKNOWN (%d)", err) < sizeof (buf));\n') -f.write (' return buf;\n') -f.write (' }\n') -f.write ('}\n') +with SuperFile('copyexec-err.h') as f: + # not using `% tuple_ for tuple_ in errors` just for clarity + for error_name, error_code in errors: + f.append('#define COPYEXEC_ERR_%s (%d)' % (error_name, error_code)) + f.append('char *copyexec_strerror (int err);') + +with SuperFile('copyexec-err.c') as f: + f.append('#include ') + f.append('#include ') + f.append('#include "copyexec-err.h"') + f.append('char *copyexec_strerror (int err) {') + f.append(' static char buf[64];') + f.append(' switch (err) {') + for error_name, error_code in errors: + f.append(' case COPYEXEC_ERR_%s: return "COPYEXEC_ERR_%s"; break;' + % (error_name, error_name)) + f.append(' default: assert (snprintf (buf, sizeof (buf), "COPYEXEC_ERR_UNKNOWN (%d)", err) < sizeof (buf));') + f.append(' return buf;') + f.append(' }') + f.append('}') From 1675512ce7000d43283ec09da6cd177cfeda3a33 Mon Sep 17 00:00:00 2001 From: Fike Etki Date: Wed, 12 Mar 2014 15:11:05 -0400 Subject: [PATCH 3/3] Whoops, forgot to remove test filename suffix --- copyexec/copyexec-err.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copyexec/copyexec-err.py b/copyexec/copyexec-err.py index be7d57f..39c482c 100755 --- a/copyexec/copyexec-err.py +++ b/copyexec/copyexec-err.py @@ -3,7 +3,7 @@ class SuperFile: def __init__(self, name): - self.path = os.path.join(sys.path[0], name + '-test') + self.path = os.path.join(sys.path[0], name) self.lines = ['/* Generated by python script */'] def __enter__(self): return self