Skip to content

Instantly share code, notes, and snippets.

View pcala64-test.c
#include <stdio.h>
#include <stdlib.h>
static unsigned long getLoongArchPage(unsigned long p) {
return p & ~0xfffUL;
}
static unsigned int lo12(unsigned int val) { return val & 0xfff; }
static long
View pcala64.c
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char *argv[])
{
long target;
long dest;
long pc;
long delta;
@heiher
heiher / cmpxchg-acquire-test.c
Last active October 10, 2023 07:14
A test case for cmpxchg acquire (3A6000)
View cmpxchg-acquire-test.c
/*
============================================================================
Name : cmpxchg-acquire-test.c
Author : WANG Rui <wangrui@loongson.cn>
Copyright : Copyright (c) 2023 Loongson
Description : A test case for cmpxchg acquire (3A6000)
============================================================================
*/
#include <stdio.h>
@heiher
heiher / lapcs.adoc
Created September 13, 2023 08:05
Procedure Call Standard for the LoongArch™ Architecture
View lapcs.adoc

Procedure Call Standard for the LoongArch™ Architecture

Abstract

This document describes the Procedure Call Standard used by the Application Binary Interface (ABI) of the LoongArch Architecture.

Keywords

@heiher
heiher / nftables.conf
Last active August 18, 2023 22:31
NfTables rules for transparent proxy
View nftables.conf
#!/usr/bin/nft -f
# vim:set ts=2 sw=2 et:
table inet mangle
delete table inet mangle
table inet mangle {
set byp4 {
type ipv4_addr
flags interval
View rust-1.70-vendor-loongarch.patch
This file has been truncated, but you can view the full file.
From 82eb33c3a5c66abb3ef255c9b474d2e36e148074 Mon Sep 17 00:00:00 2001
From: WANG Rui <wangrui@loongson.cn>
Date: Fri, 16 Jun 2023 11:15:15 +0800
Subject: [PATCH] rust: 1.70: vendor loongarch
---
vendor/libffi-sys/.cargo-checksum.json | 2 +-
vendor/libffi-sys/src/arch.rs | 20 +
vendor/libffi-sys/src/lib.rs | 4 +
.../linux-raw-sys-0.1.4/.cargo-checksum.json | 2 +-
@heiher
heiher / fanctl.c
Last active March 11, 2023 04:01
CPU Fan control for 3C5000+7A2000
View fanctl.c
/*
============================================================================
Name : fanctl.c
Author : hev <r@hev.cc>
Copyright : Copyright (c) 2023 hev
Description : CPU Fan control for 3C5000+7A2000
============================================================================
*/
#include <fcntl.h>
@heiher
heiher / cow-huge.c
Created November 16, 2022 03:22
COW testcase for Huge pages
View cow-huge.c
/*
============================================================================
Name : cow-huge.c
Author : hev <r@hev.cc>
Copyright : Copyright (c) 2022 hev
Description : COW testcase for Huge pages
============================================================================
*/
#include <stdio.h>
View shmem-fallocate.patch
diff --git a/mm/shmem.c b/mm/shmem.c
index e4c9e5c7081f..1fb3f69e19e2 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -959,11 +959,13 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
folio = shmem_get_partial_folio(inode, lstart >> PAGE_SHIFT);
if (folio) {
same_folio = lend < folio_pos(folio) + folio_size(folio);
- folio_mark_dirty(folio);
- if (!truncate_inode_partial_folio(folio, lstart, lend)) {
@heiher
heiher / atomic-mark-bench.c
Created September 13, 2022 02:45
Atomic mark benchmark
View atomic-mark-bench.c
/*
============================================================================
Name : atomic-mark-bench.c
Author : Rui Wang <wangrui@loongson.cn>
Copyright : Copyright (c) 2022 hev
Description : Atomic mark benchmark
============================================================================
*/
#include <stdio.h>