Commit Graph

169 Commits

Author SHA1 Message Date
Joel Rosdahl
b44a83b495 Merge branch 'maint'
* maint:
  Add separate counter "called for preprocessing"
  Include strerror(errno) in error messages when system calls fail

Conflicts:
	ccache.c
2011-04-03 14:58:48 +02:00
Joel Rosdahl
e5d351036c Add separate counter "called for preprocessing" 2011-04-03 14:42:33 +02:00
Joel Rosdahl
1c49fcaa79 Update util functions in ccache.h to match reality 2011-03-27 23:03:25 +02:00
Joel Rosdahl
f5b1a3a5fb Add missing void parameter for nullary function declarations 2011-03-23 21:34:45 +01:00
Joel Rosdahl
1d8ea36309 Merge branch 'maint'
* maint:
  portability: Disable support for long double in snprintf replacement
  portability: Handle system *sprintf functions with bad type signatures
  portability: Add Holger Weiß's improved snprintf replacement
2010-11-22 21:27:04 +01:00
Joel Rosdahl
1570ae33da portability: Add Holger Weiß's improved snprintf replacement 2010-11-22 21:07:35 +01:00
Joel Rosdahl
de36c5490a Let format_hash_as_string optionally not include the size suffix 2010-11-02 18:39:40 +01:00
Wilson Snyder
d887888cd2 Fix NFS object corruption
Several months ago I reported a problem with NFS corruption from three
simultaneous NFS users of ccache on the same file; two writers to the cache
and one reader.

I believe I have tracked this issue down to a race related to the use of
unlink. On NFS, unlink() is NOT atomic; so what seemed to be happening was
the second writer unlink()ed the first's object, then the reader got the
partially unlinked (truncated) object.

The following patch fixes this issue by always calling rename before a
unlink - a new x_unlink function. There are some places where temp files
are being unlinked; for performance these can remain as the ordinary
unlink.
2010-11-01 18:31:35 +01:00
Wilson Snyder
22bffd28ca Fix NFS object corruption
Several months ago I reported a problem with NFS corruption from three
simultaneous NFS users of ccache on the same file; two writers to the cache
and one reader.

I believe I have tracked this issue down to a race related to the use of
unlink. On NFS, unlink() is NOT atomic; so what seemed to be happening was
the second writer unlink()ed the first's object, then the reader got the
partially unlinked (truncated) object.

The following patch fixes this issue by always calling rename before a
unlink - a new x_unlink function. There are some places where temp files
are being unlinked; for performance these can remain as the ordinary
unlink.
2010-10-09 16:32:50 +02:00
Joel Rosdahl
83f2624dff Only create parent directories when needed to save stat() calls 2010-10-07 21:50:29 +02:00
Joel Rosdahl
f375665ef8 Add create_parent_dirs() 2010-10-07 21:49:07 +02:00
Joel Rosdahl
5d07bcfbd5 Improve basename()'s argument name 2010-10-07 21:48:29 +02:00
Joel Rosdahl
ff824c7d76 Add const to parameter to dirname() 2010-10-07 21:47:55 +02:00
Joel Rosdahl
1f1cfa864d Add size hint to read_text_file() 2010-10-05 22:40:04 +02:00
Ramiro Polla
8fd5fa1b29 Add strtok_r() replacement using strtok() 2010-09-27 08:00:04 +02:00
Ramiro Polla
00ebb752c2 Factorize win32getshell() out of win32execute() 2010-09-26 22:10:58 +02:00
Ramiro Polla
4b0f4f6d99 Export argvtos() as win32argvtos() 2010-09-26 22:10:24 +02:00
Joel Rosdahl
8d70fc3f17 Rename test_if_compressed() to file_is_compressed() 2010-09-12 16:36:48 +02:00
Joel Rosdahl
a914a97462 Don't hash .gch files twice; hash the hash instead 2010-09-05 21:43:06 +02:00
Joel Rosdahl
f38abae7e6 Add "can't use precompiled header" statistics 2010-09-05 11:44:09 +02:00
Joel Rosdahl
95f1260b50 Add hash_file2() and hash_fd2() functions that update two hash sums 2010-09-05 10:28:29 +02:00
Joel Rosdahl
0a6b820cc4 Use bool, true and false for boolean values 2010-08-29 13:26:55 +02:00
Joel Rosdahl
d8880584ec Introduce system.h 2010-08-29 11:54:08 +02:00
Joel Rosdahl
c85386d928 Extract knowledge about languages and extensions into a separate file 2010-08-29 10:50:44 +02:00
Joel Rosdahl
c358e7c801 Read files into memory instead of using mmap()
This has two benefits:

- It's more robust against file changes during reading.
- It improves performance on poor systems where mmap() doesn't use the disk
  cache.
2010-08-26 22:23:32 +02:00
Joel Rosdahl
0d16041092 Implement read_file() for reading an arbitrary file into memory 2010-08-26 22:03:33 +02:00
Joel Rosdahl
4ac86e614b Rename read_file() to read_text_file() 2010-08-26 21:07:43 +02:00
Joel Rosdahl
95dbcc38cb Add x_calloc() 2010-08-25 22:11:10 +02:00
Joel Rosdahl
d8927d46cb Add support for using precompiled headers if -fpch-preprocess is used 2010-08-21 16:46:51 +02:00
Joel Rosdahl
76a2b0f0c5 Generalize cc_log_executed_command 2010-08-14 21:14:07 +02:00
Joel Rosdahl
54fd1b1765 Put args declarations higher up in ccache.h 2010-08-14 21:14:07 +02:00
Joel Rosdahl
861184b725 Add args_set() function 2010-08-14 21:14:07 +02:00
Joel Rosdahl
65c847fa22 Add hash_equal() function 2010-08-14 21:14:07 +02:00
Joel Rosdahl
f86dbeaf3c Put functions in hash.c in a more natural order 2010-08-14 21:14:07 +02:00
Joel Rosdahl
18cc772aa6 Add support for running a custom command to identify the compiler 2010-08-11 08:17:42 +02:00
Joel Rosdahl
16b25cac09 Make reading and writing of statistics counters forward-compatible
Previously, ccache threw away counters values it didn't know about, i.e., new
counters coming from later ccache versions.
2010-08-04 11:03:40 +02:00
Joel Rosdahl
01fa3dfbf4 Explicitly set values of enum stats since they are important 2010-08-04 10:39:02 +02:00
Joel Rosdahl
52c4606d2c Move read_file from test/util.c to util.c 2010-08-03 23:09:16 +02:00
Joel Rosdahl
8c071cf6e0 Isolate knowledge of the counters data structure to stats.c 2010-08-03 17:27:41 +02:00
Joel Rosdahl
530dfe7c11 Format code to use a more consistent coding style 2010-08-01 17:20:33 +02:00
Joel Rosdahl
7daab1e4c2 Use lock files instead of POSIX locks when writing stats files
When writing a stats file, locking is now done by atomically creating a
symlink with lockfile_acquire() instead of locking with fcntl(). Updating
of the stats file while holding the lock is done using the
rename-into-place idiom since the lock may be intentionally broken by
another process, and if that happens, there should be no file corruption,
only lost information.

The major reason for the change is to be more robust against badly
implemented or configured network filesystems (e.g. NFS) where POSIX locks
may be broken in different ways.
2010-08-01 17:20:33 +02:00
Joel Rosdahl
852228dea5 Implement file locking primitives
Windows support is not yet done.
2010-08-01 17:20:33 +02:00
Joel Rosdahl
ff2a6f1b3a Add x_readlink() utility function 2010-08-01 17:20:33 +02:00
Joel Rosdahl
a98cbbc465 Introduce and use function-like macros str_eq() and str_startswith() 2010-08-01 17:20:15 +02:00
Joel Rosdahl
2538f20aab Introduce cc_reset(), enabling the test suite to reset global state 2010-08-01 17:20:15 +02:00
Joel Rosdahl
0ea9d9e0a3 Introduce x_rename(), which unlink()s destination if necessary before rename() 2010-07-21 15:15:42 +02:00
Joel Rosdahl
a9b2f164ff Add comments about which files declarations in ccache.h belong to 2010-07-18 14:10:29 +02:00
Joel Rosdahl
187817a707 Remove now unused x_asprintf() 2010-07-17 23:06:19 +02:00
Joel Rosdahl
8005f7a243 Add a function that formats a string in a handier way than x_asprintf 2010-07-17 22:51:29 +02:00
Joel Rosdahl
4e07d0ea7d Implement args_extend function 2010-07-17 18:49:12 +02:00