00001
00002
00003
00004
00005
00006
00007
00008 #include "config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: os__region_8c-source.html,v 1.1 2008/06/08 10:21:27 sebdiaz Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016
00017 #include <errno.h>
00018 #endif
00019
00020 #include "db_int.h"
00021 #include "os_jump.h"
00022
00023
00024
00025
00026
00027
00028
00029 int
00030 CDB___os_r_attach(dbenv, infop, rp)
00031 DB_ENV *dbenv;
00032 REGINFO *infop;
00033 REGION *rp;
00034 {
00035
00036 OS_VMROUNDOFF(rp->size);
00037
00038 #ifdef DB_REGIONSIZE_MAX
00039
00040 if (rp->size > DB_REGIONSIZE_MAX) {
00041 CDB___db_err(dbenv, "region size %lu is too large; maximum is %lu",
00042 (u_long)rp->size, (u_long)DB_REGIONSIZE_MAX);
00043 return (EINVAL);
00044 }
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 if (F_ISSET(dbenv, DB_ENV_PRIVATE)) {
00056 #if defined(MUTEX_NO_MALLOC_LOCKS)
00057
00058
00059
00060
00061
00062
00063
00064 if (F_ISSET(dbenv, DB_ENV_THREAD)) {
00065 CDB___db_err(dbenv, "%s",
00066 "architecture does not support locks inside process-local (malloc) memory");
00067 CDB___db_err(dbenv, "%s",
00068 "application may not specify both DB_PRIVATE and DB_THREAD");
00069 return (EINVAL);
00070 }
00071 #endif
00072 return (CDB___os_malloc(dbenv, rp->size, NULL, &infop->addr));
00073 }
00074
00075
00076 if (CDB___db_jump.j_map != NULL)
00077 return (CDB___db_jump.j_map(infop->name,
00078 rp->size, 1, 0, &infop->addr));
00079
00080 return (CDB___os_r_sysattach(dbenv, infop, rp));
00081 }
00082
00083
00084
00085
00086
00087
00088
00089 int
00090 CDB___os_r_detach(dbenv, infop, destroy)
00091 DB_ENV *dbenv;
00092 REGINFO *infop;
00093 int destroy;
00094 {
00095 REGION *rp;
00096
00097 rp = infop->rp;
00098
00099
00100 if (F_ISSET(dbenv, DB_ENV_PRIVATE)) {
00101 CDB___os_free(infop->addr, rp->size);
00102 return (0);
00103 }
00104
00105
00106 if (CDB___db_jump.j_unmap != NULL)
00107 return (CDB___db_jump.j_unmap(infop->addr, rp->size));
00108
00109 return (CDB___os_r_sysdetach(dbenv, infop, destroy));
00110 }