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

- Add elf attributes `visibility("internal")` to optimize shared libs
- Update array quoting

tcheukueppo 2 лет назад
Родитель
Сommit
8bc1405b87
3 измененных файлов с 74 добавлено и 54 удалено
  1. 11 12
      docs/maat_dev_ref/maat.md
  2. 5 4
      docs/maat_dev_ref/objects/Array.md
  3. 58 38
      src/ma_conf.h

+ 11 - 12
docs/maat_dev_ref/maat.md

@@ -128,7 +128,7 @@ Pair delimiters below are used to declare enums, arrays, hashes and regexs
 ### Examples
 
 ```
-var x = a|one two three|
+var x = qa|one two three|
 
 -- [ "Three", "Two", "One" ]
 var b = x.map(.cap).rev
@@ -149,7 +149,7 @@ and regex operators.
 ### Examples
 
 ```
-var a = a|ONE TWO THREE|
+var a = qa|ONE TWO THREE|
 a.each { .lc.say }
 
 say q"interpolation won't work"
@@ -303,6 +303,7 @@ each types here.
 - Date
 - Sys
 - Supply
+- Ma
 - Work
 - Lazy
 - Term
@@ -356,7 +357,7 @@ work {
     say "done"
 }
 
-var i = work { Inf.sleep }
+var i = work { INF.sleep }
 
 -- declare an anonymous function
 var a = { sleep 4; say "done" }
@@ -540,9 +541,9 @@ continue on to the next case by using the `proceed` instruction within the block
 ```
 -- output: Num, 42
 given 34 {
-  match Num { say "Num"; proceed }
-  match 42  { say "42" }
-  default   { say "Default" }
+    match Num { say "Num"; proceed }
+    match 42  { say "42" }
+    default   { say "Default" }
 }
 
 -- use '|' for alternation
@@ -657,7 +658,7 @@ of the number of iterations. One great advantage it offers is avoid the burdens
 conditional construct to avoid the execution of a statement.
 
 ```
-var h = h{one 1 two 2 three 3}
+var h = qm{one 1 two 2 three 3}
 
 h.each_kv {(k,v)
     once say 'only once!' if v == 1
@@ -804,18 +805,16 @@ Maat uses Perl compatible regular expressions(PCRE), see Regex object for more d
 ```
 ```
 
-# Moutines
-
-# Coroutines
+# Maatines
 
 # Supply/React
 
-```raku
+```
 ```
 
 # Packages
 
-```raku
+```
 ```
 
 # Phasers

+ 5 - 4
docs/maat_dev_ref/objects/Array.md

@@ -6,12 +6,13 @@
 
 ```
 -- Yep, we have multiple ways of declaring an Array object
-var a = a<liza madjou monthe>
+var x = [qw(one two three four)]
+var a = qa<liza madjou monthe>
 var b = ["kueppo", "cyrus", "christ"]
-var c = Array.new(2, 3, "four", a<5 6>)
+var c = Array.new(2, 3, "four", qa<5 6>)
 
-.say for a.lmap(.split) -- a{l i z a m a d j o u m o n t h e}
-.say for a.map(.split)  -- a{l i z a}, a{m a d j o u}, a{m o n t h e}
+.say for a.lmap(.split) -- qa{l i z a m a d j o u m o n t h e}
+.say for a.map(.split)  -- qa{l i z a}, qa{m a d j o u}, qa{m o n t h e}
 ```
 
 ## Methods

+ 58 - 38
src/ma_conf.h

@@ -39,18 +39,47 @@
 /* Bin file name */
 #define MAAT  maat MA_VERSION
 
+/*
+ * $$Macros used to enable some platform specific features. Either
+ * MA_IN_LINUX, MA_IN_MACOSX or MA_IN_IOS is defined in the Makefile
+ * during the build process.
+ *
+ * (Linux, SunOS, Solaris, IRIX, FreeBSD, NetBSD, AIX 4.2,
+ * HPUX 11, and other linux flavors)
+ * if MA_USE_DLOPEN is defined, Maat uses dlopen() from <dlfcn.h>
+ * to dynamically load libraries.
+ *
+ * (Windows)
+ * if MA_USE_DL_DLL is defined, Maat load libraries using native
+ * functions from Windows.
+ */
+
+/*
+ * Seems like embedded Windows does not support goodies of regular
+ * Windows, who would want to build Maat on a Windows phone afterall?
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+#define MA_USE_WINDOWS
+#define MA_USE_DL_DLL
+#endif
+
+#if defined(MA_IN_LINUX) || defined(MA_IN_LINUX) || defined(MA_IN_IOS)
+#define MA_USE_POSIX
+#define MA_USE_DLOPEN
+#endif
+
 /*
  * $$Configuring dir separator and default paths for Maat and external libs
  */
 
-/* on windows ? */
+/* On windows? */
 #if defined(_WIN32)
 
 /*
  * '!' in Windows expands to the directory of the current process' executable file.
- * In Makefile, if $(DESTDIR) expands to 'C:\\Program Files' && $(PREFIX) to 'Maat'
- * then '!' would probably expand to 'C:\\Program Files\Maat\'. We make sure multiple
- * versions of Maat can co-exist within expanded '!'.
+ * After Maat installation on Windows OS, '!' would probably expand to the path
+ * 'X:\\Program Files\Maat\'. These definitions make sure multiple versions of Maat
+ * can co-exist within 'X:\\Program Files\Maat\'
  */
 #if !defined(MA_CLIB_DEFAULT_PATH)
 #define MA_CLIB_DEFAULT_PATH  "!\\" MA_VERSION "\\lib\\",
@@ -62,7 +91,6 @@
    "!\\" MA_VERSION "\\maat\\",
 #endif
 
-/* For use elsewhere */
 #define MA_DIRSEP "\\"
 
 #else
@@ -83,46 +111,23 @@
 
 #endif
 
-/*
- * $$Macros used to enable some platform specific features. Either
- * MA_IN_LINUX, MA_IN_MACOSX or MA_IN_IOS is defined in the Makefile
- * during the build process.
- *
- * (Linux, SunOS, Solaris, IRIX, FreeBSD, NetBSD, AIX 4.2,
- * HPUX 11, and other linux flavors)
- * if MA_USE_DLOPEN is defined, Maat uses dlopen() from <dlfcn.h>
- * to dynamically load libraries.
- *
- * (Windows)
- * if MA_USE_DL_DLL is defined, Maat load libraries using native
- * functions from Windows.
- */
-
-/*
- * Seems like embedded Windows does not support goodies of regular
- * Windows, who would want to build Maat on a Windows phone afterall?
- */
-#if defined(_WIN32) && !defined(_WIN32_WCE)
-#define MA_USE_WINDOWS
-#define MA_USE_DL_DLL
-#endif
-
-#if defined(MA_IN_LINUX) || defined(MA_IN_LINUX) || defined(MA_IN_IOS)
-#define MA_USE_POSIX
-#define MA_USE_DLOPEN
-#endif
-
 /* $$Some macros which acts as utility functions */
 
 /* Get local radix character (decimal point) */
 #if !defined(mt_getradixchar)
-#define mt_getradixchar() (localeconv()->decimal_point[0])
+#define ma_getradixchar() (localeconv()->decimal_point[0])
 #endif
 
-/* $$Define attributes to mark entities as exported/imported */
+/* $$Define attributes to mark symbols during their declarations/definitions */
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__CYGWIN__)
 
+/*
+ * dllexport attribute causes the compiler to provide a global pointer to a
+ * pointer in a DLL, so that it can be referenced with the dllimport attribute
+ * (API consumer). Entities marked with MA_API are exported to the dynamic
+ * symbol table and can be accessed from the outside world as an api.
+ */
 #if #define(DEFINE)
 #define MA_API __declspec(dllexport)
 #else
@@ -135,6 +140,21 @@
 
 #endif
 
-/* $$Configuration for adaptive Number type */
+/*
+ * The attribute with visibility type "internal" is an optimization for certain
+ * versions of ELF objects where entities are marked local to shared object in
+ * which they are defined and cannot be called from another module and thus reduces
+ * the number of symbols in the dynamic symbol table.
+ *
+ * Without this attribute, check how the number of global symbols gets huge
+ * with `nm libmaat.so | grep ' T ' | wc -l`.
+ */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 302) && defined(__ELF__)
+#define MA_FUNC __attribute__((visibility("internal"))) extern
+#elif
+#define MA_FUNC extern
+#endif
+
+/* $$ */
 
 #endif