Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • addfile++
  • android-port-gme
  • android-port-prebuilt-libs
  • android-port-responsefile
  • better-lua-errors
  • changelog-test
  • changelog-test2
  • deployer-224
  • discord-rich-presence-edit
  • freebsd-support
  • huge-opt-test
  • lua-gvar-stuff
  • lua-stack-revert-test
  • magic
  • master
  • menu-clipboard-support
  • next
  • public-musicplus-libopenmpt
  • refactor-mem-get
  • sdl-dragdrop
  • sdlstuff
  • uncappedrevengeance-master-alt
  • SRB2_assets_221
  • SRB2_assets_222
  • SRB2_release_2.1.24
25 results

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
  • 1392-2-2-15-attempting-to-draw-a-hud-graphic-with-the-same-lump-name-as-a-lua-script-crashes-the
  • 21-installer-nodd
  • 2210-pre1
  • 2210-pre2
  • 2210-rc1
  • 2210-rc2
  • 2210-rc3
  • 2211-pre1
  • 2211-pre2
  • 2211-rc1
  • 2212-pre1
  • 2212-pre2
  • 2212-pre3
  • 2212-rc1
  • 2213
  • 2214-pre1
  • 2214-pre2
  • 2214-pre3
  • 2214-pre4
  • 2_2_12
  • 64-gl-log
  • COM_ImmedExecute-lua
  • DJGPP
  • accel-momentum
  • acs
  • action-args
  • alpha-fixes
  • any-resolution
  • appveyor
  • blend-locking
  • blentran
  • blua-unary-not-fix
  • boost-tickrate
  • bustablesoundz
  • cleanup-opengl
  • cleanupmusic
  • clipmidtex
  • cmake-valgrind
  • crawlacommander-sprites
  • custom-map-names
  • custom-teams
  • cutscene-cleanup
  • dd-music-bypass
  • dd-music-fix
  • delfile2
  • deprecate-lua-dedicated-server
  • dpl-2
  • dropshadows-spawning
  • dynabsp
  • emblem-drawing
  • exchndl-xp-fix
  • extra-textures
  • few-kart-lua-changes
  • ffloorclip
  • fix-167
  • fix-cvar-conflicts
  • fix-opengl-parameter-crash
  • fix-opengl-shear-roll
  • flipfuncpointers
  • fof-lightlist-fixes
  • font-FUCK
  • frictionrefactor
  • fuck-macros-1
  • gamepad-luakeydown
  • gamepad-morefixes
  • gamepad_experiments
  • gametype-refactor
  • gametype-refactor-1
  • gametype-refactor-player-spawns
  • ghost-networking
  • gif-splitting
  • grr-lj
  • hitboxviewer
  • hwr-texture-cache-refactor
  • hwrender2
  • improve-439
  • increase-maxconditionsets
  • increase-packet-tics
  • input-display
  • input-display-translucency
  • io
  • joystick-juggling-maz
  • just-in-case
  • keycodes-only
  • ksf-wadfiles
  • ld413-mp-fix
  • levelstruct
  • libpng-version-support
  • linedef-actions
  • lj-test
  • lol-states
  • loopedsounds
  • lower-unpegged-fix
  • lua-change-gametype
  • lua-command-netids
  • lua-gfx-2
  • lua-gfx-sprites
  • lua-local
  • makefile-auto-mingw-gcc
  • makefile-tinkering
  • SRB2_release_2.1
  • SRB2_release_2.1.1
  • SRB2_release_2.1.10
  • SRB2_release_2.1.11
  • SRB2_release_2.1.12
  • SRB2_release_2.1.14
  • SRB2_release_2.1.15
  • SRB2_release_2.1.16
  • SRB2_release_2.1.16a
  • SRB2_release_2.1.17
  • SRB2_release_2.1.18
  • SRB2_release_2.1.19
  • SRB2_release_2.1.2
  • SRB2_release_2.1.20
  • SRB2_release_2.1.21
  • SRB2_release_2.1.22
  • SRB2_release_2.1.23
  • SRB2_release_2.1.24
  • SRB2_release_2.1.25
  • SRB2_release_2.1.3
  • SRB2_release_2.1.4
  • SRB2_release_2.1.5
  • SRB2_release_2.1.6
  • SRB2_release_2.1.7
  • SRB2_release_2.1.8
  • SRB2_release_2.1.9
  • SRB2_release_2.2.0
  • SRB2_release_2.2.1
  • SRB2_release_2.2.10
  • SRB2_release_2.2.11
  • SRB2_release_2.2.12
  • SRB2_release_2.2.13
  • SRB2_release_2.2.15
  • SRB2_release_2.2.2
  • SRB2_release_2.2.3
  • SRB2_release_2.2.4
  • SRB2_release_2.2.5
  • SRB2_release_2.2.6
  • SRB2_release_2.2.7
  • SRB2_release_2.2.8
  • SRB2_release_2.2.9
  • td-release-v1.0.0
142 results
Show changes
Commits on Source (4)
#!/bin/bash -e #!/usr/local/bin/bash -e
path="." path="."
if [ x"$1" != x ]; then if [ x"$1" != x ]; then
path="$1" path="$1"
......
...@@ -36,11 +36,15 @@ extern UINT8 keyboard_started; ...@@ -36,11 +36,15 @@ extern UINT8 keyboard_started;
/** \brief The I_GetFreeMem function /** \brief The I_GetFreeMem function
\param total total memory in the system \return total memory in the system (in bytes)
*/
size_t I_GetTotalMem(void);
/** \brief The I_GetFreeMem function
\return free memory in the system \return free memory in the system (in bytes)
*/ */
UINT32 I_GetFreeMem(UINT32 *total); size_t I_GetFreeMem(void);
/** \brief Called by D_SRB2Loop, returns current time in tics. /** \brief Called by D_SRB2Loop, returns current time in tics.
*/ */
......
...@@ -45,6 +45,7 @@ set(SRB2_SDL2_SOURCES ...@@ -45,6 +45,7 @@ set(SRB2_SDL2_SOURCES
ogl_sdl.c ogl_sdl.c
${SRB2_SDL2_SOUNDIMPL} ${SRB2_SDL2_SOUNDIMPL}
memstats.c
) )
set(SRB2_SDL2_HEADERS set(SRB2_SDL2_HEADERS
......
...@@ -51,9 +51,9 @@ endif ...@@ -51,9 +51,9 @@ endif
# #
ifdef FREEBSD ifdef FREEBSD
OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include
SDL_CONFIG?=sdl11-config SDL_CONFIG?=sdl2-config
LDFLAGS+=-L/usr/X11R6/lib LDFLAGS+=-L/usr/X11R6/lib
LIBS+=-lipx -lkvm LIBS+=-lkvm
endif endif
# #
......
...@@ -118,6 +118,8 @@ endif ...@@ -118,6 +118,8 @@ endif
endif endif
endif endif
OBJS+=$(OBJDIR)/memstats.o
CFLAGS+=$(SDL_CFLAGS) CFLAGS+=$(SDL_CFLAGS)
LIBS:=$(SDL_LDFLAGS) $(LIBS) LIBS:=$(SDL_LDFLAGS) $(LIBS)
ifdef STATIC ifdef STATIC
......
...@@ -84,8 +84,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); ...@@ -84,8 +84,6 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#else #else
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
/*For meminfo*/
#include <sys/types.h>
#ifdef FREEBSD #ifdef FREEBSD
#include <kvm.h> #include <kvm.h>
#endif #endif
...@@ -199,6 +197,8 @@ static char returnWadPath[256]; ...@@ -199,6 +197,8 @@ static char returnWadPath[256];
#include "../byteptr.h" #include "../byteptr.h"
#endif #endif
#include "memstats.h"
/** \brief The JoyReset function /** \brief The JoyReset function
\param JoySet Joystick info to reset \param JoySet Joystick info to reset
...@@ -2940,156 +2940,14 @@ const char *I_LocateWad(void) ...@@ -2940,156 +2940,14 @@ const char *I_LocateWad(void)
return waddir; return waddir;
} }
#ifdef __linux__ size_t I_GetTotalMem(void)
#define MEMINFO_FILE "/proc/meminfo"
#define MEMTOTAL "MemTotal:"
#define MEMAVAILABLE "MemAvailable:"
#define MEMFREE "MemFree:"
#define CACHED "Cached:"
#define BUFFERS "Buffers:"
#define SHMEM "Shmem:"
/* Parse the contents of /proc/meminfo (in buf), return value of "name"
* (example: MemTotal) */
static long get_entry(const char* name, const char* buf)
{ {
long val; return GetTotalSysMem();
char* hit = strstr(buf, name);
if (hit == NULL) {
return -1;
}
errno = 0;
val = strtol(hit + strlen(name), NULL, 10);
if (errno != 0) {
CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno));
return -1;
}
return val;
} }
#endif
size_t I_GetFreeMem(void)
// quick fix for compil
UINT32 I_GetFreeMem(UINT32 *total)
{ {
#ifdef FREEBSD return GetFreeSysMem();
struct vmmeter sum;
kvm_t *kd;
struct nlist namelist[] =
{
#define X_SUM 0
{"_cnt"},
{NULL}
};
if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
{
if (total)
*total = 0L;
return 0;
}
if (kvm_nlist(kd, namelist) != 0)
{
kvm_close (kd);
if (total)
*total = 0L;
return 0;
}
if (kvm_read(kd, namelist[X_SUM].n_value, &sum,
sizeof (sum)) != sizeof (sum))
{
kvm_close(kd);
if (total)
*total = 0L;
return 0;
}
kvm_close(kd);
if (total)
*total = sum.v_page_count * sum.v_page_size;
return sum.v_free_count * sum.v_page_size;
#elif defined (SOLARIS)
/* Just guess */
if (total)
*total = 32 << 20;
return 32 << 20;
#elif defined (_WIN32)
MEMORYSTATUS info;
info.dwLength = sizeof (MEMORYSTATUS);
GlobalMemoryStatus( &info );
if (total)
*total = (UINT32)info.dwTotalPhys;
return (UINT32)info.dwAvailPhys;
#elif defined (__linux__)
/* Linux */
char buf[1024];
char *memTag;
UINT32 freeKBytes;
UINT32 totalKBytes;
INT32 n;
INT32 meminfo_fd = -1;
long Cached;
long MemFree;
long Buffers;
long Shmem;
long MemAvailable = -1;
meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
n = read(meminfo_fd, buf, 1023);
close(meminfo_fd);
if (n < 0)
{
// Error
if (total)
*total = 0L;
return 0;
}
buf[n] = '\0';
if ((memTag = strstr(buf, MEMTOTAL)) == NULL)
{
// Error
if (total)
*total = 0L;
return 0;
}
memTag += sizeof (MEMTOTAL);
totalKBytes = atoi(memTag);
if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL)
{
Cached = get_entry(CACHED, buf);
MemFree = get_entry(MEMFREE, buf);
Buffers = get_entry(BUFFERS, buf);
Shmem = get_entry(SHMEM, buf);
MemAvailable = Cached + MemFree + Buffers - Shmem;
if (MemAvailable == -1)
{
// Error
if (total)
*total = 0L;
return 0;
}
freeKBytes = MemAvailable;
}
else
{
memTag += sizeof (MEMAVAILABLE);
freeKBytes = atoi(memTag);
}
if (total)
*total = totalKBytes << 10;
return freeKBytes << 10;
#else
// Guess 48 MB.
if (total)
*total = 48<<20;
return 48<<20;
#endif
} }
const CPUInfoFlags *I_CPUInfo(void) const CPUInfoFlags *I_CPUInfo(void)
......
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2014-2020 by Sonic Team Junior
// Copyright (C) 2020 by Victor "SteelT" Fuentes
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file memstats.c
/// \brief Functions to get system memory information.
#include <stdio.h>
#ifndef errno
#include <errno.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef __linux__
#include <sys/types.h>
#define MEMINFO_FILE "/proc/meminfo"
#endif
#include "memstats.h"
#ifdef __linux__
ssize_t numread;
int meminfo_fd = -1;
long Cached;
long MemFree;
long Buffers;
long Shmem;
long MemAvailable = -1;
char procbuf[1024];
/* Parse the contents of /proc/meminfo (in buf), return value of "name"
* (example: MemTotal) */
static long linux_get_entry(const char* name, const char* buf)
{
char *memTag;
size_t totalKBytes;
long val;
char* hit = strstr(buf, name);
if (hit == NULL) {
return -1;
}
errno = 0;
val = strtol(hit + strlen(name), NULL, 10);
if (errno != 0) {
CONS_Debug(DBG_MEMORY, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno));
return -1;
}
return val;
}
static size_t linux_get_totalmem(void)
{
size_t totalKB;
char *memTag;
#define MEMTOTAL "MemTotal:"
meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
numread = read(meminfo_fd, buf, 1023);
close(meminfo_fd);
if (numread < 0)
{
// Error
return 0;
}
procbuf[numread] = '\0';
if ((memTag = strstr(buf, MEMTOTAL)) == NULL)
{
// Error
return 0;
}
memTag += sizeof (MEMTOTAL);
totalKB = atoi(memTag);
return totalKB << 10;
}
static size_t linux_get_freemem(void)
{
char *memTag;
long Cached;
long MemFree;
long Buffers;
long Shmem;
long MemAvailable = -1;
size_t freeKB;
#define MEMAVAILABLE "MemAvailable:"
#define MEMFREE "MemFree:"
#define CACHED "Cached:"
#define BUFFERS "Buffers:"
#define SHMEM "Shmem:"
meminfo_fd = open(MEMINFO_FILE, O_RDONLY);
numread = read(meminfo_fd, buf, 1023);
close(meminfo_fd);
if (numread < 0)
{
// Error
return 0;
}
procbuf[numread] = '\0';
/* Kernel is too old to support MEMAVAILABLE
so get values using old calculation
*/
if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL)
{
Cached = get_entry(CACHED, buf);
MemFree = get_entry(MEMFREE, buf);
Buffers = get_entry(BUFFERS, buf);
Shmem = get_entry(SHMEM, buf);
MemAvailable = Cached + MemFree + Buffers - Shmem;
if (MemAvailable == -1)
{
// Error
return 0;
}
freeKB = MemAvailable;
}
else
{
memTag += sizeof(MEMAVAILABLE);
freeKB = atoi(memTag);
}
return freeKB << 10;
}
#endif
#ifdef _WIN32
static size_t win_get_totalmem(void)
{
MEMORYSTATUS info;
info.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&info);
return info.dwTotalPhys;
}
static size_t win_get_freemem(void)
{
MEMORYSTATUS info;
info.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&info);
return info.dwAvailPhys;;
}
#endif
size_t GetTotalSysMem(void)
{
#ifdef __linux__
return linux_get_totalmem();
#endif
#ifdef _WIN32
return win_get_totalmem();
#endif
/* Guess 48 MB. */
return 48<<20;
}
size_t GetFreeSysMem(void)
{
#ifdef __linux__
return linux_get_freemem();
#endif
#ifdef _WIN32
return win_get_freemem();
#endif
/* Guess 48 MB. */
return 48<<20;
}
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2014-2020 by Sonic Team Junior
// Copyright (C) 2020 by Victor "SteelT" Fuentes
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file memstats.h
/// \brief Functions to get system memory information.
#ifndef __MEMSTATS_H__
#define __MEMSTATS_H__
size_t GetTotalSysMem(void);
size_t GetFreeSysMem(void);
#endif
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "doomstat.h" #include "doomstat.h"
#include "r_patch.h" #include "r_patch.h"
#include "r_picformats.h" #include "r_picformats.h"
#include "i_system.h" // I_GetFreeMem #include "i_system.h" // I_GetFreeMem, I_GetTotalMem
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
#include "z_zone.h" #include "z_zone.h"
#include "m_misc.h" // M_Memcpy #include "m_misc.h" // M_Memcpy
...@@ -106,14 +106,16 @@ static void Command_Memdump_f(void); ...@@ -106,14 +106,16 @@ static void Command_Memdump_f(void);
*/ */
void Z_Init(void) void Z_Init(void)
{ {
UINT32 total, memfree; size_t memtotal, memfree;
memset(&head, 0x00, sizeof(head)); memset(&head, 0x00, sizeof(head));
head.next = head.prev = &head; head.next = head.prev = &head;
memfree = I_GetFreeMem(&total)>>20; memtotal = I_GetTotalMem();
CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree); memfree = I_GetFreeMem();
CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(memtotal>>20), sizeu2(memfree>>20));
// Note: This allocates memory. Watch out. // Note: This allocates memory. Watch out.
COM_AddCommand("memfree", Command_Memfree_f); COM_AddCommand("memfree", Command_Memfree_f);
...@@ -791,7 +793,7 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag) ...@@ -791,7 +793,7 @@ size_t Z_TagsUsage(INT32 lowtag, INT32 hightag)
*/ */
static void Command_Memfree_f(void) static void Command_Memfree_f(void)
{ {
UINT32 freebytes, totalbytes; size_t freebytes, totalbytes;
Z_CheckHeap(-1); Z_CheckHeap(-1);
CONS_Printf("\x82%s", M_GetText("Memory Info\n")); CONS_Printf("\x82%s", M_GetText("Memory Info\n"));
...@@ -823,9 +825,10 @@ static void Command_Memfree_f(void) ...@@ -823,9 +825,10 @@ static void Command_Memfree_f(void)
#endif #endif
CONS_Printf("\x82%s", M_GetText("System Memory Info\n")); CONS_Printf("\x82%s", M_GetText("System Memory Info\n"));
freebytes = I_GetFreeMem(&totalbytes); totalbytes = I_GetTotalMem();
CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10); freebytes = I_GetFreeMem();
CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10); CONS_Printf(M_GetText(" Total physical memory: %7s KB\n"), sizeu1(totalbytes>>10));
CONS_Printf(M_GetText("Available physical memory: %7s KB\n"), sizeu2(freebytes>>10));
} }
#ifdef ZDEBUG #ifdef ZDEBUG
......