@@ -1920,19 +1920,15 @@ struct index_entry_offset_table
19201920 struct index_entry_offset entries [FLEX_ARRAY ];
19211921};
19221922
1923- #ifndef NO_PTHREADS
19241923static struct index_entry_offset_table * read_ieot_extension (const char * mmap , size_t mmap_size , size_t offset );
19251924static void write_ieot_extension (struct strbuf * sb , struct index_entry_offset_table * ieot );
1926- #endif
19271925
19281926static size_t read_eoie_extension (const char * mmap , size_t mmap_size );
19291927static void write_eoie_extension (struct strbuf * sb , git_hash_ctx * eoie_context , size_t offset );
19301928
19311929struct load_index_extensions
19321930{
1933- #ifndef NO_PTHREADS
19341931 pthread_t pthread ;
1935- #endif
19361932 struct index_state * istate ;
19371933 const char * mmap ;
19381934 size_t mmap_size ;
@@ -2010,8 +2006,6 @@ static unsigned long load_all_cache_entries(struct index_state *istate,
20102006 return consumed ;
20112007}
20122008
2013- #ifndef NO_PTHREADS
2014-
20152009/*
20162010 * Mostly randomly chosen maximum thread counts: we
20172011 * cap the parallelism to online_cpus() threads, and we want
@@ -2122,7 +2116,6 @@ static unsigned long load_cache_entries_threaded(struct index_state *istate, con
21222116
21232117 return consumed ;
21242118}
2125- #endif
21262119
21272120/* remember to discard_cache() before reading a different cache! */
21282121int do_read_index (struct index_state * istate , const char * path , int must_exist )
@@ -2135,10 +2128,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21352128 size_t mmap_size ;
21362129 struct load_index_extensions p ;
21372130 size_t extension_offset = 0 ;
2138- #ifndef NO_PTHREADS
21392131 int nr_threads , cpus ;
21402132 struct index_entry_offset_table * ieot = NULL ;
2141- #endif
21422133
21432134 if (istate -> initialized )
21442135 return istate -> cache_nr ;
@@ -2181,7 +2172,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21812172
21822173 src_offset = sizeof (* hdr );
21832174
2184- #ifndef NO_PTHREADS
2175+ if ( HAVE_THREADS ) {
21852176 nr_threads = git_config_get_index_threads ();
21862177
21872178 /* TODO: does creating more threads than cores help? */
@@ -2219,21 +2210,19 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22192210 } else {
22202211 src_offset += load_all_cache_entries (istate , mmap , mmap_size , src_offset );
22212212 }
2222- # else
2223- src_offset += load_all_cache_entries (istate , mmap , mmap_size , src_offset );
2224- #endif
2213+ } else {
2214+ src_offset += load_all_cache_entries (istate , mmap , mmap_size , src_offset );
2215+ }
22252216
22262217 istate -> timestamp .sec = st .st_mtime ;
22272218 istate -> timestamp .nsec = ST_MTIME_NSEC (st );
22282219
22292220 /* if we created a thread, join it otherwise load the extensions on the primary thread */
2230- #ifndef NO_PTHREADS
2231- if (extension_offset ) {
2221+ if (HAVE_THREADS && extension_offset ) {
22322222 int ret = pthread_join (p .pthread , NULL );
22332223 if (ret )
22342224 die (_ ("unable to join load_index_extensions thread: %s" ), strerror (ret ));
22352225 }
2236- #endif
22372226 if (!extension_offset ) {
22382227 p .src_offset = src_offset ;
22392228 load_index_extensions (& p );
@@ -2756,8 +2745,9 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
27562745 if (ce_write (& c , newfd , & hdr , sizeof (hdr )) < 0 )
27572746 return -1 ;
27582747
2759- #ifndef NO_PTHREADS
2760- nr_threads = git_config_get_index_threads ();
2748+ if (HAVE_THREADS ) {
2749+ nr_threads = git_config_get_index_threads ();
2750+
27612751 if (nr_threads != 1 ) {
27622752 int ieot_blocks , cpus ;
27632753
@@ -2787,7 +2777,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
27872777 ieot_entries = DIV_ROUND_UP (entries , ieot_blocks );
27882778 }
27892779 }
2790- #endif
2780+ }
27912781
27922782 offset = lseek (newfd , 0 , SEEK_CUR );
27932783 if (offset < 0 ) {
@@ -2871,8 +2861,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
28712861 * strip_extensions parameter as we need it when loading the shared
28722862 * index.
28732863 */
2874- #ifndef NO_PTHREADS
2875- if (ieot ) {
2864+ if (HAVE_THREADS && ieot ) {
28762865 struct strbuf sb = STRBUF_INIT ;
28772866
28782867 write_ieot_extension (& sb , ieot );
@@ -2883,7 +2872,6 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
28832872 if (err )
28842873 return -1 ;
28852874 }
2886- #endif
28872875
28882876 if (!strip_extensions && istate -> split_index ) {
28892877 struct strbuf sb = STRBUF_INIT ;
@@ -3469,7 +3457,6 @@ static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context,
34693457 strbuf_add (sb , hash , the_hash_algo -> rawsz );
34703458}
34713459
3472- #ifndef NO_PTHREADS
34733460#define IEOT_VERSION (1)
34743461
34753462static struct index_entry_offset_table * read_ieot_extension (const char * mmap , size_t mmap_size , size_t offset )
@@ -3542,4 +3529,3 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
35423529 strbuf_add (sb , & buffer , sizeof (uint32_t ));
35433530 }
35443531}
3545- #endif
0 commit comments