2323#if defined(__APPLE__) && defined(__OBJC__)
2424#import < mach/mach.h>
2525#import < mach/mach_host.h>
26+ #define CN1_LOG (fmt, ...) NSLog (@fmt, ##__VA_ARGS__)
2627#else
2728#include < time.h>
28- #define NSLog (...) printf(__VA_ARGS__); printf(" \n " )
29+ #include < stdio.h>
30+ #define CN1_LOG (fmt, ...) printf(fmt " \n " , ##__VA_ARGS__)
2931#endif
3032
3133// The amount of memory allocated between GC cycle checks (generally 30 seconds)
@@ -591,8 +593,8 @@ void codenameOneGCMark() {
591593 { long later = time (0 )-now;
592594 if (later>10000 )
593595 {
594- NSLog ( @ " GC trapped for %d seconds waiting for thread %d in slot %d (%d )" ,
595- (int )(later/1000 ),(int )t->threadId ,iter,t->threadKilled );
596+ CN1_LOG ( " GC trapped for %d seconds waiting for thread %d in slot %d (%d )" ,
597+ (int )(later/1000 ),(int )t->threadId ,iter,t->threadKilled );
596598 }
597599 }
598600 }
@@ -627,7 +629,7 @@ void codenameOneGCMark() {
627629 }
628630 if (CN1_EDT_THREAD_ID == t->threadId && agressiveAllocator) {
629631 long freeMemory = get_free_memory ();
630- NSLog ( @ " [GC] Blocking EDT as aggressive allocator, free memory=%lld " , freeMemory);
632+ CN1_LOG ( " [GC] Blocking EDT as aggressive allocator, free memory=%lld " , freeMemory);
631633
632634 }
633635
@@ -717,7 +719,7 @@ void printObjectsPostSweep(CODENAME_ONE_THREAD_STATE) {
717719 }
718720 }
719721 int actualTotalMemory = 0 ;
720- NSLog ( @ "\n\n **** There are %i - %i = %i nulls available entries out of %i objects in heap which take up %i , sweep saved %i ****" , nullSpaces, nullSpacesPreSweep, nullSpaces - nullSpacesPreSweep, t, totalAllocatedHeap, preSweepRam - totalAllocatedHeap);
722+ CN1_LOG ( " \n\n **** There are %i - %i = %i nulls available entries out of %i objects in heap which take up %i , sweep saved %i ****" , nullSpaces, nullSpacesPreSweep, nullSpaces - nullSpacesPreSweep, t, totalAllocatedHeap, preSweepRam - totalAllocatedHeap);
721723 for (int iter = 0 ; iter < cn1_array_3_id_java_util_Vector ; iter++) {
722724 if (classTypeCount[iter] > 0 ) {
723725 if (classTypeCountPreSweep[iter] - classTypeCount[iter] > 0 ) {
@@ -736,7 +738,7 @@ void printObjectsPostSweep(CODENAME_ONE_THREAD_STATE) {
736738 }
737739 }
738740 // NSLog(@"Actual ram = %i vs total mallocs = %i", actualTotalMemory, totalAllocatedHeap);
739- NSLog ( @ " **** GC cycle complete ****" );
741+ CN1_LOG ( " **** GC cycle complete ****" );
740742
741743 free (arrayOfNames);
742744#if defined(__APPLE__) && defined(__OBJC__)
@@ -774,7 +776,7 @@ void printObjectTypesInHeap(CODENAME_ONE_THREAD_STATE) {
774776 }
775777 }
776778 int actualTotalMemory = 0 ;
777- NSLog ( @ " There are %i null available entries out of %i objects in heap which take up %i " , nullSpaces, t, totalAllocatedHeap);
779+ CN1_LOG ( " There are %i null available entries out of %i objects in heap which take up %i " , nullSpaces, t, totalAllocatedHeap);
778780 for (int iter = 0 ; iter < cn1_array_3_id_java_util_Vector ; iter++) {
779781 if (classTypeCount[iter] > 0 ) {
780782 float f = ((float )classTypeCount[iter]) / ((float )t) * 100 .0f ;
@@ -792,7 +794,7 @@ void printObjectTypesInHeap(CODENAME_ONE_THREAD_STATE) {
792794 actualTotalMemory += sizeInHeapForType[iter];
793795 }
794796 }
795- NSLog ( @ " Actual ram = %i vs total mallocs = %i " , actualTotalMemory, totalAllocatedHeap);
797+ CN1_LOG ( " Actual ram = %i vs total mallocs = %i " , actualTotalMemory, totalAllocatedHeap);
796798
797799 free (arrayOfNames);
798800#if defined(__APPLE__) && defined(__OBJC__)
0 commit comments