Просмотр исходного кода

Fixed issue with Linux popen signature and old bcc.

git-svn-id: http://bmkng.googlecode.com/svn/trunk@65 2a3afde7-ceff-d69e-269d-2b6c215c828a
[email protected] 11 лет назад
Родитель
Сommit
a613e1246f
5 измененных файлов с 86 добавлено и 52 удалено
  1. 1 0
      bmk.bmx
  2. 28 0
      bmk_cores_linux.bmx
  3. 17 0
      bmk_cores_macos.bmx
  4. 33 0
      bmk_cores_win32.bmx
  5. 7 52
      bmk_ng_utils.bmx

+ 1 - 0
bmk.bmx

@@ -1,6 +1,7 @@
 '
 ' Change History :
 ' 2.20 17/07/2014 - Improved target (cross-compile) options.
+'                 - Fixed issue with Linux popen signature and old bcc.
 ' 2.19 05/06/2014 - Linux compilation fix for new bcc.
 '                 - Architecture tweaks and documentation update.
 '                 - Removed bb2bmx/convertbb option.

+ 28 - 0
bmk_cores_linux.bmx

@@ -0,0 +1,28 @@
+SuperStrict
+
+Extern
+?bmxng
+	Function popen:Byte Ptr(command:Byte Ptr, Mode:Byte Ptr)
+?Not bmxng
+	Function popen:Int(command:Byte Ptr, Mode:Byte Ptr)
+?
+End Extern
+
+Function GetCoreCount:Int()
+	Global count:Int
+
+	If Not count Then
+		Local buf:Byte[128]
+?bmxng
+		Local fp:Byte Ptr = popen("/bin/cat /proc/cpuinfo |grep -c '^processor'", "r")
+?Not bmxng
+		Local fp:Int = popen("/bin/cat /proc/cpuinfo |grep -c '^processor'", "r")
+?
+		fread_(buf, 1, 127, fp)
+		fclose_(fp)
+		count = String.FromCString(buf).ToInt()
+	End If
+
+	Return count
+End Function
+

+ 17 - 0
bmk_cores_macos.bmx

@@ -0,0 +1,17 @@
+SuperStrict
+
+Extern
+	Function sysctlbyname:Int(name:Byte Ptr, count:Int Ptr, size:Int Ptr, a:Byte Ptr, b:Int)
+End Extern
+
+Function GetCoreCount:Int()
+	Global count:Int
+
+	If Not count Then
+		Local l:Int = 4
+		sysctlbyname("hw.ncpu", Varptr count, Varptr l,Null,0)
+	End If
+
+	Return count
+End Function
+

+ 33 - 0
bmk_cores_win32.bmx

@@ -0,0 +1,33 @@
+SuperStrict
+
+' http://msdn.microsoft.com/en-us/library/ms724958(VS.85).aspx
+Extern "win32"
+	Function GetSystemInfo(info:Byte Ptr)
+End Extern
+
+Type SYSTEM_INFO
+	Field wProcessorArchitecture:Short
+	Field wReserved:Short
+	Field dwPageSize:Int
+	Field lpMinimumApplicationAddress:Byte Ptr
+	Field lpMaximumApplicationAddress:Byte Ptr
+	Field dwActiveProcessorMask:Int
+	Field dwNumberOfProcessors:Int
+	Field dwProcessorType:Int
+	Field dwAllocationGranularity:Int
+	Field wProcessorLevel:Short
+	Field wProcessorRevision:Short
+End Type
+
+Function GetCoreCount:Int()
+	Global count:Int
+
+	If Not count Then
+		Local info:SYSTEM_INFO = New SYSTEM_INFO
+		GetSystemInfo(info)
+		count = info.dwNumberOfProcessors
+	End If
+
+	Return count
+End Function
+

+ 7 - 52
bmk_ng_utils.bmx

@@ -7,7 +7,13 @@ Import BRL.System
 ?
 Import BRL.MaxLua
 
-'Import "lua_object.bmx"
+?linux
+Import "bmk_cores_linux.bmx"
+?macos
+Import "bmk_cores_macos.bmx"
+?win32
+Import "bmk_cores_win32.bmx"
+?
 
 Global utils:TMaxUtils = New TMaxUtils
 Global fsys:TSystem = New TSystem
@@ -164,54 +170,3 @@ Type TSystem
 ?
 End Type
 
-Extern
-?macos
-	Function sysctlbyname:Int(name:Byte Ptr, count:Int Ptr, size:Int Ptr, a:Byte Ptr, b:Int)
-?linux
-	Function popen:Byte Ptr(command:Byte Ptr, Mode:Byte Ptr)
-?
-End Extern
-?win32
-' http://msdn.microsoft.com/en-us/library/ms724958(VS.85).aspx
-Extern "win32"
-	Function GetSystemInfo(info:Byte Ptr)
-End Extern
-
-Type SYSTEM_INFO
-	Field wProcessorArchitecture:Short
-	Field wReserved:Short
-	Field dwPageSize:Int
-	Field lpMinimumApplicationAddress:Byte Ptr
-	Field lpMaximumApplicationAddress:Byte Ptr
-	Field dwActiveProcessorMask:Int
-	Field dwNumberOfProcessors:Int
-	Field dwProcessorType:Int
-	Field dwAllocationGranularity:Int
-	Field wProcessorLevel:Short
-	Field wProcessorRevision:Short
-End Type
-?
-
-Function GetCoreCount:Int()
-	Global count:Int
-
-	If Not count Then
-?macos
-		Local l:Int = 4
-		sysctlbyname("hw.ncpu", Varptr count, Varptr l,Null,0)
-?linux
-		Local buf:Byte[128]
-		Local fp:Byte Ptr = popen("/bin/cat /proc/cpuinfo |grep -c '^processor'", "r")
-		fread_(buf, 1, 127, fp)
-		fclose_(fp)
-		count = String.FromCString(buf).ToInt()
-?win32
-		Local info:SYSTEM_INFO = New SYSTEM_INFO
-		GetSystemInfo(info)
-		count = info.dwNumberOfProcessors
-?
-	End If
-
-	Return count
-End Function
-