<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/shm.c, branch 1.6.3</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.6.3</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.6.3'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-01-23T09:18:30Z</updated>
<entry>
<title>shm: don’t check for __i386__ and __x86_64__ - there are other architectures out there</title>
<updated>2021-01-23T09:18:30Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-01-21T11:39:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=1f745655ac985a78b97f5457c5f5b7251bb028a8'/>
<id>urn:sha1:1f745655ac985a78b97f5457c5f5b7251bb028a8</id>
<content type='text'>
Instead, check for __SIZEOF_POINTER__ == 8, since what we’re really
interested in is whether we have enough virtual address space or not.
</content>
</entry>
<entry>
<title>shm: unbreak build without memfd_create</title>
<updated>2021-01-23T09:16:37Z</updated>
<author>
<name>Jan Beich</name>
<email>jbeich@FreeBSD.org</email>
</author>
<published>2021-01-19T14:20:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fcf3f124d626afbc2438756efb7605a4324eb94d'/>
<id>urn:sha1:fcf3f124d626afbc2438756efb7605a4324eb94d</id>
<content type='text'>
New FreeBSD versions have memfd_create but other BSDs don't.

pgo/pgo.c:260:22: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        int mem_fd = memfd_create("foot-pgo-ptmx", MFD_CLOEXEC);
                     ^
pgo/pgo.c:260:52: error: use of undeclared identifier 'MFD_CLOEXEC'
        int mem_fd = memfd_create("foot-pgo-ptmx", MFD_CLOEXEC);
                                                   ^
shm.c:13:10: fatal error: 'linux/mman.h' file not found
 #include &lt;linux/mman.h&gt;
          ^~~~~~~~~~~~~~
shm.c:277:15: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING);
              ^
shm.c:277:60: error: use of undeclared identifier 'MFD_CLOEXEC'
    pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING);
                                                           ^
shm.c:277:74: error: use of undeclared identifier 'MFD_ALLOW_SEALING'
    pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING);
                                                                         ^
shm.c:339:15: error: use of undeclared identifier 'F_SEAL_GROW'
              F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) &lt; 0)
              ^
shm.c:339:29: error: use of undeclared identifier 'F_SEAL_SHRINK'
              F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) &lt; 0)
                            ^
shm.c:339:71: error: use of undeclared identifier 'F_SEAL_SEAL'
              F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) &lt; 0)
                                                                      ^
shm.c:338:24: error: use of undeclared identifier 'F_ADD_SEALS'
    if (fcntl(pool_fd, F_ADD_SEALS,
                       ^
</content>
</entry>
<entry>
<title>shm: disable fallocate optimization if not supported</title>
<updated>2021-01-23T09:16:34Z</updated>
<author>
<name>Jan Beich</name>
<email>jbeich@FreeBSD.org</email>
</author>
<published>2021-01-19T15:22:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=93fd77e01b25f2cec62b252e077d48f73dc76c9a'/>
<id>urn:sha1:93fd77e01b25f2cec62b252e077d48f73dc76c9a</id>
<content type='text'>
shm.c:301:26: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        can_punch_hole = fallocate(
                         ^
shm.c:302:22: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
            pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
                     ^
shm.c:302:45: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
            pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
                                            ^
shm.c:432:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (fallocate(
        ^
shm.c:434:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
            ^
shm.c:434:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                   ^
shm.c:501:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (fallocate(
        ^
shm.c:503:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
            ^
shm.c:503:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                   ^
shm.c:597:9: error: implicit declaration of function 'fallocate' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (fallocate(
        ^
shm.c:599:13: error: use of undeclared identifier 'FALLOC_FL_PUNCH_HOLE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
            ^
shm.c:599:36: error: use of undeclared identifier 'FALLOC_FL_KEEP_SIZE'
            FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
                                   ^
</content>
</entry>
<entry>
<title>shm: silence -Wunused-function on i386</title>
<updated>2021-01-23T09:16:31Z</updated>
<author>
<name>Jan Beich</name>
<email>jbeich@FreeBSD.org</email>
</author>
<published>2021-01-19T15:17:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6626ef5807a65bba514a80cad6a2a4312cb73cb1'/>
<id>urn:sha1:6626ef5807a65bba514a80cad6a2a4312cb73cb1</id>
<content type='text'>
shm.c:134:1: error: unused function 'page_size' [-Werror,-Wunused-function]
page_size(void)
^
</content>
</entry>
<entry>
<title>shm: fix badly indented function return type</title>
<updated>2020-12-07T19:44:11Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-12-04T17:42:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=85cdc66ff2e11704ab33f27095681ec886f6d721'/>
<id>urn:sha1:85cdc66ff2e11704ab33f27095681ec886f6d721</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: MAP_UNINITIALIZED is a linux only mmap flag</title>
<updated>2020-10-10T09:29:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-10-10T09:29:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9e0fcb1c27cf5980e4f7fc280a2a33fa6c188355'/>
<id>urn:sha1:9e0fcb1c27cf5980e4f7fc280a2a33fa6c188355</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fix some buggy comparisons relating to signed/unsigned types</title>
<updated>2020-08-25T18:39:17Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-25T18:39:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f3acfea81565edf38ca7546fe4a351126d04442a'/>
<id>urn:sha1:f3acfea81565edf38ca7546fe4a351126d04442a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Cast printf formatter %p arguments to void*</title>
<updated>2020-08-23T08:07:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-08-23T05:50:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e32c0d9bf698782353bbe9e4348617523af473bd'/>
<id>urn:sha1:e32c0d9bf698782353bbe9e4348617523af473bd</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: don't even try to punch a memfd hole in 32-bit</title>
<updated>2020-08-11T15:22:12Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-08-11T15:22:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=732e181b1d360425cf1b4853158e266ad4f07384'/>
<id>urn:sha1:732e181b1d360425cf1b4853158e266ad4f07384</id>
<content type='text'>
This ensures we don't issue a warning if we fail, something that will
just confuse users, as SHM scrolling is disabled in 32-bit anyway.
</content>
</entry>
<entry>
<title>Convert most dynamic allocations to use functions from xmalloc.h</title>
<updated>2020-08-08T19:37:57Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-08T19:34:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7a77958ba20c2b344be5e66e69e2f212a4bbf6b3'/>
<id>urn:sha1:7a77958ba20c2b344be5e66e69e2f212a4bbf6b3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Replace GCC "unused" and "format" attributes with portable macros</title>
<updated>2020-08-07T19:42:34Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-07T19:42:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7eb70a453b4ea797d9e85017c6deab6a7bc903a6'/>
<id>urn:sha1:7eb70a453b4ea797d9e85017c6deab6a7bc903a6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: re-write cell clipping to use pixman destination clipping</title>
<updated>2020-06-04T13:39:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-06-04T13:39:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8b320ed29630e75c058bbf368ea5e2e9a68d0143'/>
<id>urn:sha1:8b320ed29630e75c058bbf368ea5e2e9a68d0143</id>
<content type='text'>
Our home rolled clip-to-cell code was, obviously, not correct.

The original problem was that we couldn't use pixman clipping since we
have multiple threads writing to the same pixman image, and thus there
would be races between the threads setting clipping.

The fix is actually simple - just instantiate one pixman
image (referencing the same backing image data) for each rendering
thread.
</content>
</entry>
<entry>
<title>shm: #ifdef conditional code to measure total size of SHM allocations</title>
<updated>2020-04-18T10:24:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-04-18T10:24:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4f145bed33d1de87993f947cb7fad31130fc868f'/>
<id>urn:sha1:4f145bed33d1de87993f947cb7fad31130fc868f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: memfd seal failures are not fatal errors</title>
<updated>2020-04-03T18:14:53Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-04-03T18:14:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a2081047432c58481592e3e8155017fbbdf6c1da'/>
<id>urn:sha1:a2081047432c58481592e3e8155017fbbdf6c1da</id>
<content type='text'>
</content>
</entry>
<entry>
<title>conf: max-shm-pool-size-mb=0 now disables SHM scrolling</title>
<updated>2020-03-26T17:04:30Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-26T17:04:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c4aaba6299b092cd8221fb6e8c301fe5bfd602a4'/>
<id>urn:sha1:c4aaba6299b092cd8221fb6e8c301fe5bfd602a4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: make max pool size user configurable (via a 'tweak' setting)</title>
<updated>2020-03-25T19:48:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T19:48:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0baa249d8b59007913dbf7db8aa8d94e6c2b9d44'/>
<id>urn:sha1:0baa249d8b59007913dbf7db8aa8d94e6c2b9d44</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: handle ftruncate failure</title>
<updated>2020-03-25T17:32:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:32:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e9f1638750db342fbf26fc9477a970ab2e3e439d'/>
<id>urn:sha1:e9f1638750db342fbf26fc9477a970ab2e3e439d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: seal the memfd</title>
<updated>2020-03-25T17:30:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:30:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=dc42cc1d195a16683c45fc87eb2dc333087a90da'/>
<id>urn:sha1:dc42cc1d195a16683c45fc87eb2dc333087a90da</id>
<content type='text'>
This both prevents accidental resizing of the memfd, and allows the
Wayland server to optimze reads from the buffer - it no longer has to
setup SIGBUS handlers.
</content>
</entry>
<entry>
<title>shm: scroll: keep shm pool around, and fix its size at max allowed</title>
<updated>2020-03-25T17:26:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-25T17:26:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=03319560f5c7c908b1c1d229b3ba53ed1ac6b692'/>
<id>urn:sha1:03319560f5c7c908b1c1d229b3ba53ed1ac6b692</id>
<content type='text'>
This lessens the burden on (primarily) the compositor, since we no
longer tear down and re-create the SHM pool when scrolling.

The SHM pool is setup once, and its size is fixed at the maximum
allowed (512MB for now, 2GB would be possible).

This also allows us to mmap() the memfd once. The exposed raw pointer
is simply an offset from the memfd mmapping.

Note that this means e.g. rouge rendering code will be able to write
outside the buffer.

Finally, only do this if the caller explicitly wants to enable
scrolling. The memfd of other buffers are sized to the requested size.
</content>
</entry>
<entry>
<title>shm: scroll: implement offset wrap-around</title>
<updated>2020-03-24T16:46:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-03-24T16:46:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c5f1d096c3a2a6cb8fb3dc5cb3efad5782c1d78'/>
<id>urn:sha1:5c5f1d096c3a2a6cb8fb3dc5cb3efad5782c1d78</id>
<content type='text'>
* Impose a maximum memfd size limit. In theory, this can be
  2GB (wl_shm_create_pool() is the limiting factor - its size argument
  is an int32_t). For now, use 256MB.

  This is mainly to reduce the amount of virtual address space used by
  the compositor, which keeps at least one mmapping (of the entire
  memfd) around. One mmapping *per terminal window* that is.

  Given that we have 128TB with 48-bit virtual addresses, we could
  probably bump this to 2GB without any issues. However, 256MB should
  be enough.

  TODO: check how much we typically move the offset when scrolling in
  a fullscreen window on a 4K monitor. 256MB may turn out to be too
  small.

  On 32-bit shm_scroll() is completely disabled. There simply isn't
  enough address space.

* Wrapping is done by moving the offset to "the other end" of the
  memfd, and copying the buffer contents to the new, wrapped offset.

  The "normal" scrolling code then does the actual scrolling. This
  means we'll re-instantiate all objects twice when wrapping.
</content>
</entry>
</feed>
