utf16_to_utf8() should croak on encountering a bare low surrogate.
[p5sagit/p5-mst-13.2.git] / ext / DynaLoader / dl_dyld.xs
index 2ac2baa..b7ae161 100644 (file)
@@ -9,11 +9,13 @@
  */
 
 /*
-    And Gandalf said: 'Many folk like to know beforehand what is to
-    be set on the table; but those who have laboured to prepare the
-    feast like to keep their secret; for wonder makes the words of
-    praise louder.'
-*/
+ *  And Gandalf said: 'Many folk like to know beforehand what is to
+ *  be set on the table; but those who have laboured to prepare the
+ *  feast like to keep their secret; for wonder makes the words of
+ *  praise louder.'
+ *
+ *     [p.970 of _The Lord of the Rings_, VI/v: "The Steward and the King"]
+ */
 
 /* Porting notes:
 
@@ -54,8 +56,7 @@ static char *dlerror()
     return dl_last_error;
 }
 
-static int dlclose(handle) /* stub only */
-void *handle;
+static int dlclose(void *handle) /* stub only */
 {
     return 0;
 }
@@ -98,8 +99,7 @@ static void TranslateError
                     path, number, type);
        break;
     }
-    safefree(dl_last_error);
-    dl_last_error = savepv(error);
+    sv_setpv(MY_CXT.x_dl_last_error, error);
 }
 
 static char *dlopen(char *path, int mode /* mode is ignored */)
@@ -113,7 +113,7 @@ static char *dlopen(char *path, int mode /* mode is ignored */)
        TranslateError(path, OFImage, dyld_result);
     else
     {
-       // NSLinkModule will cause the run to abort on any link error's
+       // NSLinkModule will cause the run to abort on any link errors
        // not very friendly but the error recovery functionality is limited.
        handle = NSLinkModule(ofile, path, TRUE);
        NSDestroyObjectFileImage(ofile);
@@ -123,9 +123,7 @@ static char *dlopen(char *path, int mode /* mode is ignored */)
 }
 
 static void *
-dlsym(handle, symbol)
-void *handle;
-char *symbol;
+dlsym(void *handle, char *symbol)
 {
     void *addr;
 
@@ -205,13 +203,14 @@ void
 dl_install_xsub(perl_name, symref, filename="$Package")
     char *     perl_name
     void *     symref
-    char *     filename
+    const char *       filename
     CODE:
     DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%x)\n",
            perl_name, symref));
-    ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name,
-                                       (void(*)(pTHX_ CV *))symref,
-                                       filename)));
+    ST(0) = sv_2mortal(newRV((SV*)newXS_flags(perl_name,
+                                             (void(*)(pTHX_ CV *))symref,
+                                             filename, NULL,
+                                             XS_DYNAMIC_FILENAME)));
 
 
 char *
@@ -222,4 +221,19 @@ dl_error()
     OUTPUT:
     RETVAL
 
+#if defined(USE_ITHREADS)
+
+void
+CLONE(...)
+    CODE:
+    MY_CXT_CLONE;
+
+    /* MY_CXT_CLONE just does a memcpy on the whole structure, so to avoid
+     * using Perl variables that belong to another thread, we create our 
+     * own for this thread.
+     */
+    MY_CXT.x_dl_last_error = newSVpvn("", 0);
+
+#endif
+
 # end.