/[gentoo-alt]/trunk/overlay/media-libs/jpeg/files/60_all_jpeg-maxmem-sysconf.patch
Gentoo

Contents of /trunk/overlay/media-libs/jpeg/files/60_all_jpeg-maxmem-sysconf.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1288 - (show annotations) (download)
Mon May 29 00:51:19 2006 UTC (8 years, 3 months ago) by flameeyes
File size: 1310 byte(s)
Add jpeg with portable patch for maxmem support.
1 # Make a reasonable guess about memory limits using sysconf().
2 # includes 5% slop factor as suggested in documentation.
3
4 Index: jpeg-6b/jmemansi.c
5 ===================================================================
6 --- jpeg-6b.orig/jmemansi.c
7 +++ jpeg-6b/jmemansi.c
8 @@ -12,6 +12,15 @@
9 * is shoved onto the user.
10 */
11
12 +#include <unistd.h>
13 +
14 +#ifdef __FreeBSD__
15 +#include <sys/types.h>
16 +#include <sys/sysctl.h>
17 +#include <sys/vmmeter.h>
18 +#include <vm/vm_param.h>
19 +#endif
20 +
21 #define JPEG_INTERNALS
22 #include "jinclude.h"
23 #include "jpeglib.h"
24 @@ -157,7 +166,24 @@ jpeg_open_backing_store (j_common_ptr ci
25 GLOBAL(long)
26 jpeg_mem_init (j_common_ptr cinfo)
27 {
28 - return DEFAULT_MAX_MEM; /* default for max_memory_to_use */
29 +#ifdef _SC_AVPHYS_PAGES
30 + long phys_size;
31 +
32 + if ((phys_size = sysconf(_SC_AVPHYS_PAGES)) == -1)
33 + return DEFAULT_MAX_MEM; /* default for max_memory_to_use */
34 + if ((phys_size *= sysconf(_SC_PAGESIZE)) < 0)
35 + return DEFAULT_MAX_MEM;
36 + return (long) (phys_size * 0.95);
37 +#elif defined(__FreeBSD__)|| defined(__DragonFly__)
38 + int mib[2] = { CTL_VM, VM_METER }
39 + struct vmtotal memory;
40 + size_t len = sizeof(memory);
41 +
42 + sysctl(mib, 2, &memory, &len, NULL, 0);
43 + return (long) (memory->t_free * getpagesize() * 0.95);
44 +#endif
45 +
46 + return DEFAULT_MAX_MEM;
47 }
48
49 GLOBAL(void)

  ViewVC Help
Powered by ViewVC 1.1.20