Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix casting for GCC 14+ #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/test-n-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,30 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
python-major-version: [3]
python-minor-version: [8, 9, 10, 11, 12, 13]
env:
python-version: ${{ format('{0}.{1}', matrix.python-major-version, matrix.python-minor-version) }}


steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Set up Python ${{ matrix.python-version }}
with:
python-version: ${{ matrix.python-version }}
- name: Install
- name: Install Pip
run: |
python -m pip install --upgrade pip
- name: Install Python dependencies
run: |
python -m pip install codecov requests
- name: Install Python setuptools
if: ${{ (matrix.python-major-version == 3 && matrix.python-minor-version >= 12) || matrix.python-major-version > 3 }}
run: |
python -m pip install setuptools
- name: Install PyCacheSim
run: |
python -m pip install -e .
- name: Test
run: |
Expand Down
20 changes: 13 additions & 7 deletions cachesim/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ Cache* get_cacheSim_from_file(const char* cache_file)
if (line[0] != '\n' && line[0] != '\r' && line[0] != '#')
{
cacheSim[counter] = (Cache*) calloc(1, sizeof(Cache));
if (&cacheSim[counter] == NULL)
if (cacheSim[counter] == NULL)
{
fprintf(file, "allocation of memory for cache object failed\n");
fflush(file);
Expand Down Expand Up @@ -1358,6 +1358,9 @@ Cache* get_cacheSim_from_file(const char* cache_file)

}

#ifndef NO_PYTHON
#define CAST_CACHE_SIM_TO_PYOBJ (PyObject*)
#endif
//link caches
fputs("\nlink caches:\n",file);
fflush(file);
Expand All @@ -1370,17 +1373,17 @@ Cache* get_cacheSim_from_file(const char* cache_file)
if(cacheSim[j]->name != NULL){
if (load_from_buff[i] != NULL && strcmp(load_from_buff[i], cacheSim[j]->name) == 0)
{
cacheSim[i]->load_from = cacheSim[j];
cacheSim[i]->load_from = CAST_CACHE_SIM_TO_PYOBJ cacheSim[j];
++linkcounter[j];
}
if (store_to_buff[i] != NULL && strcmp(store_to_buff[i], cacheSim[j]->name) == 0)
{
cacheSim[i]->store_to = cacheSim[j];
cacheSim[i]->store_to = CAST_CACHE_SIM_TO_PYOBJ cacheSim[j];
++linkcounter[j];
}
if (victims_to_buff[i] != NULL && strcmp(victims_to_buff[i], cacheSim[j]->name) == 0)
{
cacheSim[i]->victims_to = cacheSim[j];
cacheSim[i]->victims_to = CAST_CACHE_SIM_TO_PYOBJ cacheSim[j];
++linkcounter[j];
}
}
Expand Down Expand Up @@ -1434,6 +1437,9 @@ Cache* get_cacheSim_from_file(const char* cache_file)

//has to be left out when using pin, as stdout for some reason cannot be linked in this case
#ifndef USE_PIN
#ifndef NO_PYTHON
#define CAST_PYOBJ_TO_CACHE (Cache*)
#endif
void printStats(Cache* cache)
{
fprintf(stdout, "%s:\n",cache->name);
Expand All @@ -1444,10 +1450,10 @@ void printStats(Cache* cache)
fprintf(stdout, "EVICT: %llu size: %lluB\n",cache->EVICT.count, cache->EVICT.byte);

if (cache->load_from != NULL)
printStats(cache->load_from);
printStats(CAST_PYOBJ_TO_CACHE cache->load_from);
if (cache->store_to != NULL && cache->store_to != cache->load_from)
printStats(cache->store_to);
printStats(CAST_PYOBJ_TO_CACHE cache->store_to);
if (cache->victims_to != NULL && cache->store_to != cache->load_from && cache->store_to != cache->victims_to)
printStats(cache->victims_to);
printStats(CAST_PYOBJ_TO_CACHE cache->victims_to);
}
#endif
Loading