diff options
| author | Andrea Corallo | 2020-05-24 21:59:25 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-05-24 21:59:25 +0100 |
| commit | 0bba0e367b4b5378501de7c91838ea2de8b4af4a (patch) | |
| tree | 4e47cc7a901115be9b954d033031cb539c19f1ec /src | |
| parent | 1bc558b77e648efa905076f793d28fc0f025ae50 (diff) | |
| download | emacs-0bba0e367b4b5378501de7c91838ea2de8b4af4a.tar.gz emacs-0bba0e367b4b5378501de7c91838ea2de8b4af4a.zip | |
Fix GNU style
* src/comp.h: Fix GNU style.
* src/comp.c (Fcomp__compile_ctxt_to_file): Likewise.
* lisp/emacs-lisp/comp.el (comp--replace-output-file): Likewise.
* src/pdumper.c (dump_do_dump_relocation): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp.c | 151 | ||||
| -rw-r--r-- | src/comp.h | 7 | ||||
| -rw-r--r-- | src/pdumper.c | 2 |
3 files changed, 78 insertions, 82 deletions
diff --git a/src/comp.c b/src/comp.c index 16ad77c74bc..b4e3e2e887f 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -3883,7 +3883,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, | |||
| 3883 | GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY, | 3883 | GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY, |
| 3884 | SSDATA (tmp_file)); | 3884 | SSDATA (tmp_file)); |
| 3885 | 3885 | ||
| 3886 | CALL2I(comp--replace-output-file, out_file, tmp_file); | 3886 | CALL2I (comp--replace-output-file, out_file, tmp_file); |
| 3887 | 3887 | ||
| 3888 | if (!noninteractive) | 3888 | if (!noninteractive) |
| 3889 | unbind_to (count, Qnil); | 3889 | unbind_to (count, Qnil); |
| @@ -3953,67 +3953,68 @@ helper_PSEUDOVECTOR_TYPEP_XUNTAG (Lisp_Object a, enum pvec_type code) | |||
| 3953 | /*********************************/ | 3953 | /*********************************/ |
| 3954 | 3954 | ||
| 3955 | /* | 3955 | /* |
| 3956 | The problem: Windows does not let us delete an .eln file that has been | 3956 | The problem: Windows does not let us delete an .eln file that has |
| 3957 | loaded by a process. This has two implications in Emacs: | 3957 | been loaded by a process. This has two implications in Emacs: |
| 3958 | 3958 | ||
| 3959 | 1) It is not possible to recompile a lisp file if the corresponding | 3959 | 1) It is not possible to recompile a lisp file if the corresponding |
| 3960 | .eln file has been loaded. This is because we'd like to use the same | 3960 | .eln file has been loaded. This is because we'd like to use the same |
| 3961 | filename, but we can't delete the old .eln file. | 3961 | filename, but we can't delete the old .eln file. |
| 3962 | 3962 | ||
| 3963 | 2) It is not possible to delete a package using `package-delete' | 3963 | 2) It is not possible to delete a package using `package-delete' |
| 3964 | if an .eln file has been loaded. | 3964 | if an .eln file has been loaded. |
| 3965 | 3965 | ||
| 3966 | * General idea | 3966 | * General idea |
| 3967 | 3967 | ||
| 3968 | The solution to these two problems is to move the foo.eln file | 3968 | The solution to these two problems is to move the foo.eln file |
| 3969 | somewhere else and have the last Emacs instance using it delete it. | 3969 | somewhere else and have the last Emacs instance using it delete it. |
| 3970 | To make it easy to find what files need to be removed we use two approaches. | 3970 | To make it easy to find what files need to be removed we use two approaches. |
| 3971 | 3971 | ||
| 3972 | In the 1) case we rename foo.eln to fooXXXXXX.eln.old in the same | 3972 | In the 1) case we rename foo.eln to fooXXXXXX.eln.old in the same |
| 3973 | folder. When Emacs is unloading "foo" (either GC'd the native | 3973 | folder. When Emacs is unloading "foo" (either GC'd the native |
| 3974 | compilation unit or Emacs is closing (see below)) we delete all the | 3974 | compilation unit or Emacs is closing (see below)) we delete all the |
| 3975 | .eln.old files in the folder where the original foo.eln was stored. | 3975 | .eln.old files in the folder where the original foo.eln was stored. |
| 3976 | 3976 | ||
| 3977 | Ideally we'd figure out the new name of foo.eln and delete it if | 3977 | Ideally we'd figure out the new name of foo.eln and delete it if it |
| 3978 | it ends in .eln.old. There is no simple API to do this in | 3978 | ends in .eln.old. There is no simple API to do this in Windows. |
| 3979 | Windows. GetModuleFileName() returns the original filename, not the | 3979 | GetModuleFileName () returns the original filename, not the current |
| 3980 | current one. This forces us to put .eln.old files in an agreed upon | 3980 | one. This forces us to put .eln.old files in an agreed upon path. |
| 3981 | path. We cannot use %TEMP% because it may be in another drive and then | 3981 | We cannot use %TEMP% because it may be in another drive and then the |
| 3982 | the rename operation would fail. | 3982 | rename operation would fail. |
| 3983 | 3983 | ||
| 3984 | In the 2) case we can't use the same folder where the .eln file | 3984 | In the 2) case we can't use the same folder where the .eln file |
| 3985 | resided, as we are trying to completely remove the package. Since we | 3985 | resided, as we are trying to completely remove the package. Since we |
| 3986 | are removing packages we can safely move the .eln.old file to | 3986 | are removing packages we can safely move the .eln.old file to |
| 3987 | `package-user-dir' as we are sure that that would not mean changing | 3987 | `package-user-dir' as we are sure that that would not mean changing |
| 3988 | drives. | 3988 | drives. |
| 3989 | 3989 | ||
| 3990 | * Implementation details | 3990 | * Implementation details |
| 3991 | 3991 | ||
| 3992 | The concept of disposal of a native compilation unit refers to | 3992 | The concept of disposal of a native compilation unit refers to |
| 3993 | unloading the shared library and deleting all the .eln.old files in | 3993 | unloading the shared library and deleting all the .eln.old files in |
| 3994 | the directory. These are two separate steps. We'll call them | 3994 | the directory. These are two separate steps. We'll call them |
| 3995 | early-disposal and late-disposal. | 3995 | early-disposal and late-disposal. |
| 3996 | 3996 | ||
| 3997 | There are two data structures used: | 3997 | There are two data structures used: |
| 3998 | 3998 | ||
| 3999 | - The `all_loaded_comp_units_h` hashtable. | 3999 | - The `all_loaded_comp_units_h` hashtable. |
| 4000 | 4000 | ||
| 4001 | This hashtable is used like an array of weak references to native | 4001 | This hashtable is used like an array of weak references to native |
| 4002 | compilation units. This hash table is filled by load_comp_unit() and | 4002 | compilation units. This hash table is filled by load_comp_unit () |
| 4003 | dispose_all_remaining_comp_units() iterates over all values that were | 4003 | and dispose_all_remaining_comp_units () iterates over all values |
| 4004 | not disposed by the GC and performs all disposal steps when Emacs is | 4004 | that were not disposed by the GC and performs all disposal steps |
| 4005 | closing. | 4005 | when Emacs is closing. |
| 4006 | 4006 | ||
| 4007 | - The `delayed_comp_unit_disposal_list` list. | 4007 | - The `delayed_comp_unit_disposal_list` list. |
| 4008 | 4008 | ||
| 4009 | This is were the dispose_comp_unit() function, when called by the GC | 4009 | This is were the dispose_comp_unit () function, when called by the |
| 4010 | sweep stage, stores the original filenames of the disposed native | 4010 | GC sweep stage, stores the original filenames of the disposed native |
| 4011 | compilation units. This is an ad-hoc C structure instead of a Lisp | 4011 | compilation units. This is an ad-hoc C structure instead of a Lisp |
| 4012 | cons because we need to allocate instances of this structure during | 4012 | cons because we need to allocate instances of this structure during |
| 4013 | the GC. | 4013 | the GC. |
| 4014 | 4014 | ||
| 4015 | The finish_delayed_disposal_of_comp_units() function will iterate over | 4015 | The finish_delayed_disposal_of_comp_units () function will iterate |
| 4016 | this list and perform the late-disposal step when Emacs is closing. | 4016 | over this list and perform the late-disposal step when Emacs is |
| 4017 | closing. | ||
| 4017 | 4018 | ||
| 4018 | */ | 4019 | */ |
| 4019 | 4020 | ||
| @@ -4022,9 +4023,8 @@ this list and perform the late-disposal step when Emacs is closing. | |||
| 4022 | 4023 | ||
| 4023 | static Lisp_Object all_loaded_comp_units_h; | 4024 | static Lisp_Object all_loaded_comp_units_h; |
| 4024 | 4025 | ||
| 4025 | /* We need to allocate instances of this struct during a GC | 4026 | /* We need to allocate instances of this struct during a GC sweep. |
| 4026 | * sweep. This is why it can't be transformed into a simple cons. | 4027 | This is why it can't be transformed into a simple cons. */ |
| 4027 | */ | ||
| 4028 | struct delayed_comp_unit_disposal | 4028 | struct delayed_comp_unit_disposal |
| 4029 | { | 4029 | { |
| 4030 | struct delayed_comp_unit_disposal *next; | 4030 | struct delayed_comp_unit_disposal *next; |
| @@ -4041,9 +4041,8 @@ return_nil (Lisp_Object arg) | |||
| 4041 | 4041 | ||
| 4042 | /* Tries to remove all *.eln.old files in DIRNAME. | 4042 | /* Tries to remove all *.eln.old files in DIRNAME. |
| 4043 | 4043 | ||
| 4044 | * Any error is ignored because it may be due to the file being loaded | 4044 | Any error is ignored because it may be due to the file being loaded |
| 4045 | * in another Emacs instance. | 4045 | in another Emacs instance. */ |
| 4046 | */ | ||
| 4047 | static void | 4046 | static void |
| 4048 | clean_comp_unit_directory (Lisp_Object dirpath) | 4047 | clean_comp_unit_directory (Lisp_Object dirpath) |
| 4049 | { | 4048 | { |
| @@ -4058,9 +4057,8 @@ clean_comp_unit_directory (Lisp_Object dirpath) | |||
| 4058 | 4057 | ||
| 4059 | /* Tries to remove all *.eln.old files in `package-user-dir'. | 4058 | /* Tries to remove all *.eln.old files in `package-user-dir'. |
| 4060 | 4059 | ||
| 4061 | * This is called when Emacs is closing to clean any *.eln left from a | 4060 | This is called when Emacs is closing to clean any *.eln left from a |
| 4062 | * deleted package. | 4061 | deleted package. */ |
| 4063 | */ | ||
| 4064 | void | 4062 | void |
| 4065 | clean_package_user_dir_of_old_comp_units (void) | 4063 | clean_package_user_dir_of_old_comp_units (void) |
| 4066 | { | 4064 | { |
| @@ -4073,10 +4071,10 @@ clean_package_user_dir_of_old_comp_units (void) | |||
| 4073 | } | 4071 | } |
| 4074 | 4072 | ||
| 4075 | /* This function disposes all compilation units that are still loaded. | 4073 | /* This function disposes all compilation units that are still loaded. |
| 4076 | * It is important that this function is called only right before | 4074 | |
| 4077 | * Emacs is closed, otherwise we risk running a subr that is | 4075 | It is important that this function is called only right before |
| 4078 | * implemented in an unloaded dynamic library. | 4076 | Emacs is closed, otherwise we risk running a subr that is |
| 4079 | */ | 4077 | implemented in an unloaded dynamic library. */ |
| 4080 | void | 4078 | void |
| 4081 | dispose_all_remaining_comp_units (void) | 4079 | dispose_all_remaining_comp_units (void) |
| 4082 | { | 4080 | { |
| @@ -4095,11 +4093,10 @@ dispose_all_remaining_comp_units (void) | |||
| 4095 | } | 4093 | } |
| 4096 | 4094 | ||
| 4097 | /* This function finishes the disposal of compilation units that were | 4095 | /* This function finishes the disposal of compilation units that were |
| 4098 | * passed to `dispose_comp_unit` with DELAY == true. | 4096 | passed to `dispose_comp_unit` with DELAY == true. |
| 4099 | * | 4097 | |
| 4100 | * This function is called when Emacs is idle and when it is about to | 4098 | This function is called when Emacs is idle and when it is about to |
| 4101 | * close. | 4099 | close. */ |
| 4102 | */ | ||
| 4103 | void | 4100 | void |
| 4104 | finish_delayed_disposal_of_comp_units (void) | 4101 | finish_delayed_disposal_of_comp_units (void) |
| 4105 | { | 4102 | { |
| @@ -4118,8 +4115,7 @@ finish_delayed_disposal_of_comp_units (void) | |||
| 4118 | #endif | 4115 | #endif |
| 4119 | 4116 | ||
| 4120 | /* This function puts the compilation unit in the | 4117 | /* This function puts the compilation unit in the |
| 4121 | * `all_loaded_comp_units_h` hashmap. | 4118 | `all_loaded_comp_units_h` hashmap. */ |
| 4122 | */ | ||
| 4123 | static void | 4119 | static void |
| 4124 | register_native_comp_unit (Lisp_Object comp_u) | 4120 | register_native_comp_unit (Lisp_Object comp_u) |
| 4125 | { | 4121 | { |
| @@ -4128,14 +4124,13 @@ register_native_comp_unit (Lisp_Object comp_u) | |||
| 4128 | #endif | 4124 | #endif |
| 4129 | } | 4125 | } |
| 4130 | 4126 | ||
| 4131 | /* This function disposes compilation units. It is called during the GC sweep | 4127 | /* This function disposes compilation units. It is called during the GC sweep |
| 4132 | * stage and when Emacs is closing. | 4128 | stage and when Emacs is closing. |
| 4133 | 4129 | ||
| 4134 | * On Windows the the DELAY parameter specifies whether the native | 4130 | On Windows the the DELAY parameter specifies whether the native |
| 4135 | * compilation file will be deleted right away (if necessary) or put | 4131 | compilation file will be deleted right away (if necessary) or put |
| 4136 | * on a list. That list will be dealt with by | 4132 | on a list. That list will be dealt with by |
| 4137 | * `finish_delayed_disposal_of_comp_units`. | 4133 | `finish_delayed_disposal_of_comp_units`. */ |
| 4138 | */ | ||
| 4139 | void | 4134 | void |
| 4140 | dispose_comp_unit (struct Lisp_Native_Comp_Unit *comp_handle, bool delay) | 4135 | dispose_comp_unit (struct Lisp_Native_Comp_Unit *comp_handle, bool delay) |
| 4141 | { | 4136 | { |
| @@ -4387,10 +4382,10 @@ load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump, | |||
| 4387 | data_imp_relocs[i] = AREF (comp_u->data_impure_vec, i); | 4382 | data_imp_relocs[i] = AREF (comp_u->data_impure_vec, i); |
| 4388 | 4383 | ||
| 4389 | /* If we register them while dumping we will get some entries in | 4384 | /* If we register them while dumping we will get some entries in |
| 4390 | the hash table that will be duplicated when pdumper calls | 4385 | the hash table that will be duplicated when pdumper calls |
| 4391 | load_comp_unit. */ | 4386 | load_comp_unit. */ |
| 4392 | if (!will_dump_p ()) | 4387 | if (!will_dump_p ()) |
| 4393 | register_native_comp_unit (comp_u_lisp_obj); | 4388 | register_native_comp_unit (comp_u_lisp_obj); |
| 4394 | } | 4389 | } |
| 4395 | 4390 | ||
| 4396 | if (!loading_dump) | 4391 | if (!loading_dump) |
| @@ -4701,7 +4696,7 @@ syms_of_comp (void) | |||
| 4701 | 4696 | ||
| 4702 | #ifdef WINDOWSNT | 4697 | #ifdef WINDOWSNT |
| 4703 | staticpro (&all_loaded_comp_units_h); | 4698 | staticpro (&all_loaded_comp_units_h); |
| 4704 | all_loaded_comp_units_h = CALLN(Fmake_hash_table, QCweakness, Qvalue); | 4699 | all_loaded_comp_units_h = CALLN (Fmake_hash_table, QCweakness, Qvalue); |
| 4705 | #endif | 4700 | #endif |
| 4706 | 4701 | ||
| 4707 | DEFVAR_LISP ("comp-ctxt", Vcomp_ctxt, | 4702 | DEFVAR_LISP ("comp-ctxt", Vcomp_ctxt, |
diff --git a/src/comp.h b/src/comp.h index 18c5ba12298..c6f23dc1468 100644 --- a/src/comp.h +++ b/src/comp.h | |||
| @@ -57,9 +57,9 @@ struct Lisp_Native_Comp_Unit | |||
| 57 | #ifdef WINDOWSNT | 57 | #ifdef WINDOWSNT |
| 58 | /* We need to store a copy of the original file name in memory that | 58 | /* We need to store a copy of the original file name in memory that |
| 59 | is not subject to GC because the function to dispose native | 59 | is not subject to GC because the function to dispose native |
| 60 | compilation units is called by the GC. By that time the `file' | 60 | compilation units is called by the GC. By that time the `file' |
| 61 | string may have been sweeped. */ | 61 | string may have been sweeped. */ |
| 62 | char * cfile; | 62 | char *cfile; |
| 63 | #endif | 63 | #endif |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| @@ -92,7 +92,8 @@ extern void syms_of_comp (void); | |||
| 92 | extern void maybe_defer_native_compilation (Lisp_Object function_name, | 92 | extern void maybe_defer_native_compilation (Lisp_Object function_name, |
| 93 | Lisp_Object definition); | 93 | Lisp_Object definition); |
| 94 | 94 | ||
| 95 | extern void dispose_comp_unit (struct Lisp_Native_Comp_Unit * comp_unit, bool delay); | 95 | extern void dispose_comp_unit (struct Lisp_Native_Comp_Unit * comp_unit, |
| 96 | bool delay); | ||
| 96 | 97 | ||
| 97 | extern void finish_delayed_disposal_of_comp_units (void); | 98 | extern void finish_delayed_disposal_of_comp_units (void); |
| 98 | 99 | ||
diff --git a/src/pdumper.c b/src/pdumper.c index 26480388d59..b40a29c02ac 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -5313,7 +5313,7 @@ dump_do_dump_relocation (const uintptr_t dump_base, | |||
| 5313 | installation_state == LOCAL_BUILD | 5313 | installation_state == LOCAL_BUILD |
| 5314 | ? XCDR (comp_u->file) : XCAR (comp_u->file)); | 5314 | ? XCDR (comp_u->file) : XCAR (comp_u->file)); |
| 5315 | #ifdef WINDOWSNT | 5315 | #ifdef WINDOWSNT |
| 5316 | comp_u->cfile = xlispstrdup(comp_u->file); | 5316 | comp_u->cfile = xlispstrdup (comp_u->file); |
| 5317 | #endif | 5317 | #endif |
| 5318 | comp_u->handle = dynlib_open (SSDATA (comp_u->file)); | 5318 | comp_u->handle = dynlib_open (SSDATA (comp_u->file)); |
| 5319 | if (!comp_u->handle) | 5319 | if (!comp_u->handle) |