CMUCL commit: src/lisp (backtrace.c os-common.c)

Raymond Toy rtoy at common-lisp.net
Mon Feb 1 20:27:08 CET 2010


    Date: Monday, February 1, 2010 @ 14:27:08
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/lisp

Modified: backtrace.c os-common.c

Simplify UNICODE conditionalization by using convert_lisp_string
everywhere, not just for unicode.  Non-unicode takes a small hit from
doing an unnecessary strcpy, but that should not be critical.


-------------+
 backtrace.c |   24 +-----------------------
 os-common.c |   34 ++++++++++++----------------------
 2 files changed, 13 insertions(+), 45 deletions(-)


Index: src/lisp/backtrace.c
diff -u src/lisp/backtrace.c:1.20 src/lisp/backtrace.c:1.21
--- src/lisp/backtrace.c:1.20	Mon Nov  2 10:05:07 2009
+++ src/lisp/backtrace.c	Mon Feb  1 14:27:07 2010
@@ -1,4 +1,4 @@
-/* $Header: /project/cmucl/cvsroot/src/lisp/backtrace.c,v 1.20 2009-11-02 15:05:07 rtoy Exp $
+/* $Header: /project/cmucl/cvsroot/src/lisp/backtrace.c,v 1.21 2010-02-01 19:27:07 rtoy Exp $
  *
  * Simple backtrace facility.  More or less from Rob's lisp version.
  */
@@ -214,16 +214,10 @@
 		    }
 		    if (TypeOf(*object) == type_SimpleString) {
 			struct vector *string;
-#ifdef UNICODE
                         char c_string[1000];
-#endif                        
 			string = (struct vector *) object;
-#ifdef UNICODE
                         convert_lisp_string(c_string, string->data, string->length >> 2);
 			printf("%s, ", c_string);
-#else
-                        printf("%s, ", (char *) string->data);
-#endif
 		    } else
 			printf("(Not simple string??\?), ");
 		} else
@@ -295,42 +289,26 @@
 	if (TypeOf(*object) == type_SymbolHeader) {
 	    struct symbol *symbol = (struct symbol *) object;
 	    struct vector *string;
-#ifdef UNICODE
 	    char c_string[1000];
-#endif
 
 	    if (symbol->package != NIL) {
 		struct instance *pkg = (struct instance *) PTR(symbol->package);
 		lispobj pkg_name = pkg->slots[2];
 
 		string = (struct vector *) PTR(pkg_name);
-#ifndef UNICODE
-		printf("%s::", (char *) string->data);
-#else
 		convert_lisp_string(c_string, string->data, string->length >> 2);
 		printf("%s:;", c_string);
-#endif
 	    }
 
 	    object = (lispobj *) PTR(symbol->name);
 	    string = (struct vector *) object;
-#ifndef UNICODE
-	    printf("%s", (char *) string->data);
-#else
 	    convert_lisp_string(c_string, string->data, string->length >> 2);
 	    printf("%s:;", c_string);
-#endif
 	} else if (TypeOf(*object) == type_SimpleString) {
 	    struct vector *string = (struct vector *) object;
-#ifdef UNICODE
 	    char c_string[1000];
-#endif
-#ifndef UNICODE
-	    printf("\"%s\"", (char *) string->data);
-#else
 	    convert_lisp_string(c_string, string->data, string->length >> 2);
 	    printf("\"%s\"", c_string);
-#endif
 	} else
 	    printf("<??? type %d>", (int) TypeOf(*object));
     } else
Index: src/lisp/os-common.c
diff -u src/lisp/os-common.c:1.30 src/lisp/os-common.c:1.31
--- src/lisp/os-common.c:1.30	Thu Jul 16 09:02:16 2009
+++ src/lisp/os-common.c	Mon Feb  1 14:27:07 2010
@@ -1,6 +1,6 @@
 /*
 
- $Header: /project/cmucl/cvsroot/src/lisp/os-common.c,v 1.30 2009-07-16 13:02:16 rtoy Rel $
+ $Header: /project/cmucl/cvsroot/src/lisp/os-common.c,v 1.31 2010-02-01 19:27:07 rtoy Exp $
 
  This code was written as part of the CMU Common Lisp project at
  Carnegie Mellon University, and has been placed in the public domain.
@@ -145,15 +145,16 @@
 #define LINKAGE_DATA_ENTRY_SIZE 3
 #endif
 
-#ifdef UNICODE
-/*
- * FIXME:
- * Unicode hack to convert Lisp 16-bit string to 8-bit string by lopping off the high bits.
- */
 
 char*
 convert_lisp_string(char* c_string, void* lisp_string, int len)
 {
+#ifdef UNICODE    
+   /*
+    * FIXME: Unicode hack to convert Lisp 16-bit string to 8-bit string
+    * by lopping off the high bits.
+    */
+
     int k;
     unsigned short int* wide_string = (unsigned short int*) lisp_string;
 
@@ -161,10 +162,12 @@
         c_string[k] = (wide_string[k]) & 0xff;
     }
     c_string[k] = 0;
-    
+#else
+    strcpy(c_string, lisp_string);
+#endif
+
     return c_string;
 }
-#endif
 
 void
 os_foreign_linkage_init(void)
@@ -184,7 +187,6 @@
 	    = (struct vector *) PTR(data_vector->data[i]);
 	long type = fixnum_value(data_vector->data[i + 1]);
 	lispobj lib_list = data_vector->data[i + 2];
-#ifdef UNICODE
         /* FIXME:  1000 may not be long enough.  Add checks to make sure it's ok!!!!*/
         char c_symbol_name[1000];
 	/*
@@ -193,9 +195,6 @@
 	 */
 
         convert_lisp_string(c_symbol_name, symbol_name->data, (symbol_name->length >> 2));
-#else
-#define c_symbol_name ((char*) symbol_name->data)
-#endif                            
 	if (i == 0) {
 #if defined(sparc)
 	    if (type != LINKAGE_CODE_TYPE || strcmp(c_symbol_name, "call_into_c")) {
@@ -261,13 +260,10 @@
 	    = (struct vector *) PTR(data_vector->data[i]);
 	long type = fixnum_value(data_vector->data[i + 1]);
 	lispobj lib_list = data_vector->data[i + 2];
-#ifdef UNICODE
         char c_symbol_name[1000];
 
         convert_lisp_string(c_symbol_name, symbol_name->data, (symbol_name->length >> 2));
-#else
-#define c_symbol_name ((char*) symbol_name->data)
-#endif
+
 	if (type == LINKAGE_DATA_TYPE && lib_list != NIL) {
 	    void *target_addr = os_dlsym(c_symbol_name, lib_list);
 
@@ -299,9 +295,7 @@
     long type;
     void *target_addr;
     long table_index = entry * LINKAGE_DATA_ENTRY_SIZE;
-#ifdef UNICODE
     char c_symbol_name[1000];
-#endif    
 
     linkage_data = (struct array *) PTR(linkage_data_obj);
     table_size = fixnum_value(linkage_data->fill_pointer);
@@ -312,11 +306,7 @@
     symbol_name = (struct vector *) PTR(data_vector->data[table_index]);
     type = fixnum_value(data_vector->data[table_index + 1]);
 
-#ifdef UNICODE
     convert_lisp_string(c_symbol_name, symbol_name->data, (symbol_name->length >> 2));
-#else
-#define c_symbol_name ((char*) symbol_name->data)
-#endif
     
     target_addr = os_dlsym(c_symbol_name,
 			   data_vector->data[table_index + 2]);



More information about the cmucl-commit mailing list