Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 388:aabb7f5b1c81 r21-2-9
Import from CVS: tag r21-2-9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:09:42 +0200 |
parents | 8626e4521993 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
387:f892a9d0bb8d | 388:aabb7f5b1c81 |
---|---|
3178 } | 3178 } |
3179 #else | 3179 #else |
3180 #define check_sane_subr(subr, sym) /* nothing */ | 3180 #define check_sane_subr(subr, sym) /* nothing */ |
3181 #endif | 3181 #endif |
3182 | 3182 |
3183 #ifdef HAVE_SHLIB | |
3184 /* | |
3185 * If we are not in a pure undumped Emacs, we need to make a duplicate of | |
3186 * the subr. This is because the only time this function will be called | |
3187 * in a running Emacs is when a dynamically loaded module is adding a | |
3188 * subr, and we need to make sure that the subr is in allocated, Lisp- | |
3189 * accessible memory. The address assigned to the static subr struct | |
3190 * in the shared object will be a trampoline address, so we need to create | |
3191 * a copy here to ensure that a real address is used. | |
3192 * | |
3193 * Once we have copied everything across, we re-use the original static | |
3194 * structure to store a pointer to the newly allocated one. This will be | |
3195 * used in emodules.c by emodules_doc_subr() to find a pointer to the | |
3196 * allocated object so that we can set its doc string propperly. | |
3197 * | |
3198 * NOTE: We dont actually use the DOC pointer here any more, but we did | |
3199 * in an earlier implementation of module support. There is no harm in | |
3200 * setting it here in case we ever need it in future implementations. | |
3201 * subr->doc will point to the new subr structure that was allocated. | |
3202 * Code can then get this value from the statis subr structure and use | |
3203 * it if required. | |
3204 * | |
3205 * FIXME: Should newsubr be staticpro()'ed? I dont think so but I need | |
3206 * a guru to check. | |
3207 */ | |
3208 #define check_module_subr() \ | |
3209 do { \ | |
3210 if (initialized) { \ | |
3211 struct Lisp_Subr *newsubr; \ | |
3212 newsubr = (Lisp_Subr *)xmalloc(sizeof(struct Lisp_Subr)); \ | |
3213 memcpy (newsubr, subr, sizeof(struct Lisp_Subr)); \ | |
3214 subr->doc = (CONST char *)newsubr; \ | |
3215 subr = newsubr; \ | |
3216 } \ | |
3217 } while (0) | |
3218 #else /* ! HAVE_SHLIB */ | |
3219 #define check_module_subr() | |
3220 #endif | |
3221 | |
3183 void | 3222 void |
3184 defsubr (Lisp_Subr *subr) | 3223 defsubr (Lisp_Subr *subr) |
3185 { | 3224 { |
3186 Lisp_Object sym = intern (subr_name (subr)); | 3225 Lisp_Object sym = intern (subr_name (subr)); |
3187 Lisp_Object fun; | 3226 Lisp_Object fun; |
3188 | 3227 |
3189 check_sane_subr (subr, sym); | 3228 check_sane_subr (subr, sym); |
3229 check_module_subr (); | |
3190 | 3230 |
3191 XSETSUBR (fun, subr); | 3231 XSETSUBR (fun, subr); |
3192 XSYMBOL (sym)->function = fun; | 3232 XSYMBOL (sym)->function = fun; |
3193 } | 3233 } |
3194 | 3234 |
3198 { | 3238 { |
3199 Lisp_Object sym = intern (subr_name (subr)); | 3239 Lisp_Object sym = intern (subr_name (subr)); |
3200 Lisp_Object fun; | 3240 Lisp_Object fun; |
3201 | 3241 |
3202 check_sane_subr (subr, sym); | 3242 check_sane_subr (subr, sym); |
3243 check_module_subr(); | |
3203 | 3244 |
3204 XSETSUBR (fun, subr); | 3245 XSETSUBR (fun, subr); |
3205 XSYMBOL (sym)->function = Fcons (Qmacro, fun); | 3246 XSYMBOL (sym)->function = Fcons (Qmacro, fun); |
3206 } | 3247 } |
3207 | 3248 |
3319 struct symbol_value_forward *p = xnew (struct symbol_value_forward); | 3360 struct symbol_value_forward *p = xnew (struct symbol_value_forward); |
3320 memcpy (p, magic, sizeof *magic); | 3361 memcpy (p, magic, sizeof *magic); |
3321 magic = p; | 3362 magic = p; |
3322 } | 3363 } |
3323 | 3364 |
3324 sym = Fintern (make_pure_pname ((CONST Bufbyte *) symbol_name, | 3365 #if defined(HAVE_SHLIB) |
3325 strlen (symbol_name), | 3366 /* |
3326 1), | 3367 * As with defsubr(), this will only be called in a dumped Emacs when |
3327 Qnil); | 3368 * we are adding variables from a dynamically loaded module. That means |
3369 * we can't use purespace. Take that into account. | |
3370 */ | |
3371 if (initialized) | |
3372 sym = Fintern (build_string (symbol_name), Qnil); | |
3373 else | |
3374 #endif | |
3375 sym = Fintern (make_pure_pname ((CONST Bufbyte *) symbol_name, | |
3376 strlen (symbol_name), 1), Qnil); | |
3377 | |
3328 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic); | 3378 XSETOBJ (XSYMBOL (sym)->value, Lisp_Type_Record, magic); |
3329 } | 3379 } |
3330 | 3380 |
3331 void | 3381 void |
3332 vars_of_symbols (void) | 3382 vars_of_symbols (void) |