< prev index next >

src/java.base/share/native/libjava/jni_util.h

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 372  */
 373 enum {
 374     NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
 375     NO_FAST_ENCODING,           /* Platform encoding is not fast */
 376     FAST_8859_1,                /* ISO-8859-1 */
 377     FAST_CP1252,                /* MS-DOS Cp1252 */
 378     FAST_646_US                 /* US-ASCII : ISO646-US */
 379 };
 380 
 381 int getFastEncoding();
 382 
 383 void initializeEncoding();
 384 
 385 void* getProcessHandle();
 386 
 387 void buildJniFunctionName(const char *sym, const char *cname,
 388                           char *jniEntryName);
 389 
 390 extern size_t getLastErrorString(char *buf, size_t len);
 391 extern int getErrorString(int err, char *buf, size_t len);















































































































 392 #ifdef __cplusplus
 393 } /* extern "C" */
 394 #endif /* __cplusplus */
 395 
 396 #endif /* JNI_UTIL_H */
   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 372  */
 373 enum {
 374     NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
 375     NO_FAST_ENCODING,           /* Platform encoding is not fast */
 376     FAST_8859_1,                /* ISO-8859-1 */
 377     FAST_CP1252,                /* MS-DOS Cp1252 */
 378     FAST_646_US                 /* US-ASCII : ISO646-US */
 379 };
 380 
 381 int getFastEncoding();
 382 
 383 void initializeEncoding();
 384 
 385 void* getProcessHandle();
 386 
 387 void buildJniFunctionName(const char *sym, const char *cname,
 388                           char *jniEntryName);
 389 
 390 extern size_t getLastErrorString(char *buf, size_t len);
 391 extern int getErrorString(int err, char *buf, size_t len);
 392 
 393 #ifdef STATIC_BUILD
 394 /* Macros for handling declaration of static/dynamic
 395  * JNI library Load/Unload functions
 396  *
 397  * Use DEF_JNI_On{Un}Load when you want a static and non-static entry points.
 398  * Use DEF_STATIC_JNI_On{Un}Load when you only want a static one.
 399  *
 400  * LIBRARY_NAME must be set to the name of the library
 401  */
 402 
 403 /* These three macros are needed to get proper concatenation of
 404  * the LIBRARY_NAME
 405  *
 406  * NOTE: LIBRARY_NAME must be set for static builds.
 407  */
 408 #define ADD_LIB_NAME3(name, lib) name ## lib
 409 #define ADD_LIB_NAME2(name, lib) ADD_LIB_NAME3(name, lib)
 410 #define ADD_LIB_NAME(entry) ADD_LIB_NAME2(entry, LIBRARY_NAME)
 411 
 412 #define DEF_JNI_OnLoad \
 413 ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) \
 414 { \
 415   jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)(JavaVM *vm, void *reserved); \
 416   ADD_LIB_NAME(JNI_OnLoad_dynamic_)(vm, reserved); \
 417   return JNI_VERSION_1_8; \
 418 } \
 419 jint JNICALL ADD_LIB_NAME(JNI_OnLoad_dynamic_)
 420 
 421 #define DEF_STATIC_JNI_OnLoad \
 422 JNIEXPORT jint JNICALL ADD_LIB_NAME(JNI_OnLoad_)(JavaVM *vm, void *reserved) { \
 423     return JNI_VERSION_1_8; \
 424 }
 425 
 426 #define DEF_JNI_OnUnload \
 427 ADD_LIB_NAME(JNI_OnUnload_)(JavaVM *vm, void *reserved) \
 428 { \
 429   void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)(JavaVM *vm, void *reserved); \
 430   ADD_LIB_NAME(JNI_OnUnload_dynamic_)(vm, reserved); \
 431 } \
 432 void JNICALL ADD_LIB_NAME(JNI_OnUnload_dynamic_)
 433 
 434 #define DEF_STATIC_JNI_OnUnload \
 435 ADD_LIB_NAME(JNI_OnUnload_)
 436 
 437 #else
 438 
 439 #define DEF_JNI_OnLoad JNI_OnLoad
 440 #define DEF_STATIC_JNI_OnLoad
 441 #define DEF_JNI_OnUnload JNI_OnUnload
 442 #define DEF_STATIC_JNI_OnUnload
 443 #endif
 444 
 445 #ifdef STATIC_BUILD
 446 /* Macros for handling declaration of static/dynamic
 447  * Agent library Load/Attach/Unload functions
 448  *
 449  * Use DEF_Agent_OnLoad, DEF_Agent_OnAttach or DEF_Agent_OnUnload
 450  *     when you want both static and non-static entry points.
 451  * Use DEF_STATIC_Agent_OnLoad, DEF_STATIC_Agent_OnAttach or
 452  *     DEF_STATIC_Agent_OnUnload when you only want a static one.
 453  *
 454  * LIBRARY_NAME must be set to the name of the library for static builds.
 455  */
 456 
 457 #define DEF_Agent_OnLoad \
 458 ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) \
 459 { \
 460   jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)(JavaVM *vm, char *options, void *reserved); \
 461   return ADD_LIB_NAME(Agent_OnLoad_dynamic_)(vm, options, reserved); \
 462 } \
 463 jint JNICALL ADD_LIB_NAME(Agent_OnLoad_dynamic_)
 464 
 465 #define DEF_STATIC_Agent_OnLoad \
 466 JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
 467     return JNI_FALSE; \
 468 }
 469 
 470 #define DEF_Agent_OnAttach \
 471 ADD_LIB_NAME(Agent_OnAttach_)(JavaVM *vm, char *options, void *reserved) \
 472 { \
 473   jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)(JavaVM *vm, char *options, void *reserved); \
 474   return ADD_LIB_NAME(Agent_OnAttach_dynamic_)(vm, options, reserved); \
 475 } \
 476 jint JNICALL ADD_LIB_NAME(Agent_OnAttach_dynamic_)
 477 
 478 #define DEF_STATIC_Agent_OnAttach \
 479 JNIEXPORT jint JNICALL ADD_LIB_NAME(Agent_OnLoad_)(JavaVM *vm, char *options, void *reserved) { \
 480     return JNI_FALSE; \
 481 }
 482 
 483 #define DEF_Agent_OnUnload \
 484 ADD_LIB_NAME(Agent_OnUnload_)(JavaVM *vm) \
 485 { \
 486   void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)(JavaVM *vm); \
 487   ADD_LIB_NAME(Agent_OnUnload_dynamic_)(vm); \
 488 } \
 489 void JNICALL ADD_LIB_NAME(Agent_OnUnload_dynamic_)
 490 
 491 #define DEF_STATIC_Agent_OnUnload \
 492 ADD_LIB_NAME(Agent_OnUnload_)
 493 
 494 #else
 495 #define DEF_Agent_OnLoad Agent_OnLoad
 496 #define DEF_Agent_OnAttach Agent_OnAttach
 497 #define DEF_Agent_OnUnload Agent_OnUnload
 498 #define DEF_STATIC_Agent_OnLoad
 499 #define DEF_STATIC_Agent_OnAttach
 500 #define DEF_STATIC_Agent_OnUnload
 501 #endif
 502 
 503 #ifdef __cplusplus
 504 } /* extern "C" */
 505 #endif /* __cplusplus */
 506 
 507 #endif /* JNI_UTIL_H */
< prev index next >