< prev index next >

src/jdk.pack200/share/native/common-unpack/utils.cpp

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) 2001, 2011, 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


  60   }
  61   mtrace('m', ptr, size);
  62   return ptr;
  63 }
  64 
  65 void mkdirs(int oklen, char* path) {
  66 
  67   if (strlen(path) <= (size_t)oklen)  return;
  68   char dir[PATH_MAX];
  69 
  70   strcpy(dir, path);
  71   char* slash = strrchr(dir, '/');
  72   if (slash == 0)  return;
  73   *slash = 0;
  74   mkdirs(oklen, dir);
  75   MKDIR(dir);
  76 }
  77 
  78 
  79 #ifndef PRODUCT


  80 void breakpoint() { }  // hook for debugger
  81 int assert_failed(const char* p) {
  82   char message[1<<12];
  83   sprintf(message, "@assert failed: %s\n", p);
  84   fprintf(stdout, "%s", 1+message);
  85   breakpoint();
  86   unpack_abort(message);
  87   return 0;
  88 }

  89 #endif
  90 
  91 void unpack_abort(const char* msg, unpacker* u) {
  92   if (msg == null)  msg = "corrupt pack file or internal error";
  93   if (u == null)
  94     u = unpacker::current();
  95   if (u == null) {
  96     fprintf(stderr, "Error: unpacker: %s\n", msg);
  97     ::abort();
  98     return;
  99   }
 100   u->abort(msg);
 101 }
 102 
 103 bool unpack_aborting(unpacker* u) {
 104   if (u == null)
 105     u = unpacker::current();
 106   if (u == null) {
 107     fprintf(stderr, "Error: unpacker: no current instance\n");
 108     ::abort();


   1 /*
   2  * Copyright (c) 2001, 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


  60   }
  61   mtrace('m', ptr, size);
  62   return ptr;
  63 }
  64 
  65 void mkdirs(int oklen, char* path) {
  66 
  67   if (strlen(path) <= (size_t)oklen)  return;
  68   char dir[PATH_MAX];
  69 
  70   strcpy(dir, path);
  71   char* slash = strrchr(dir, '/');
  72   if (slash == 0)  return;
  73   *slash = 0;
  74   mkdirs(oklen, dir);
  75   MKDIR(dir);
  76 }
  77 
  78 
  79 #ifndef PRODUCT
  80 #ifndef STATIC_BUILD
  81 // use the definition in libjvm when building statically
  82 void breakpoint() { }  // hook for debugger
  83 int assert_failed(const char* p) {
  84   char message[1<<12];
  85   sprintf(message, "@assert failed: %s\n", p);
  86   fprintf(stdout, "%s", 1+message);
  87   breakpoint();
  88   unpack_abort(message);
  89   return 0;
  90 }
  91 #endif
  92 #endif
  93 
  94 void unpack_abort(const char* msg, unpacker* u) {
  95   if (msg == null)  msg = "corrupt pack file or internal error";
  96   if (u == null)
  97     u = unpacker::current();
  98   if (u == null) {
  99     fprintf(stderr, "Error: unpacker: %s\n", msg);
 100     ::abort();
 101     return;
 102   }
 103   u->abort(msg);
 104 }
 105 
 106 bool unpack_aborting(unpacker* u) {
 107   if (u == null)
 108     u = unpacker::current();
 109   if (u == null) {
 110     fprintf(stderr, "Error: unpacker: no current instance\n");
 111     ::abort();


< prev index next >